本文整理匯總了Java中org.springframework.jms.annotation.JmsListener類的典型用法代碼示例。如果您正苦於以下問題:Java JmsListener類的具體用法?Java JmsListener怎麽用?Java JmsListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JmsListener類屬於org.springframework.jms.annotation包,在下文中一共展示了JmsListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: receiveEntityEventHistoryMessage
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
/**
* JMS Internal Listener for Your Microservice Entity Event History Messages.
* @param yourEntityEventHistory Payload of the Message to be Handled.
*/
@JmsListener(destination = "your.microservice.entity.event.history")
public void receiveEntityEventHistoryMessage(YourEntityEventHistory yourEntityEventHistory) {
/**
* Perform some basic Validation.
*/
if (yourEntityEventHistory == null) {
LOGGER.warn("Received YourEntityEventHistory Message, however payload was null, Ignoring.");
return;
}
if (yourEntityEventHistory.getEventTagProperties() == null || yourEntityEventHistory.getEventTagProperties().isEmpty()) {
LOGGER.warn("Receive YourEntityEventHistory Message, however Tag Properties were null or empty, Ignoring.");
return;
}
/**
* Show Debug Message
*/
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Received Message:[" + yourEntityEventHistory.toString() + "]");
}
/**
* Persist the Event ...
*/
identityProviderEntityManager.createEventHistory(yourEntityEventHistory);
}
示例2: getDeepCrawling
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
@Override
@JmsListener(destination = "CRAWL_WEBSITES")
public void getDeepCrawling(String urlString) throws URISyntaxException {
LOG.info("Received " + urlString);
WebsiteModel seedWebsite = new WebsiteModel();
seedWebsite.setUrl(urlString);
putItemResultMono(urlString, EStatus.PROCESSING, null, null).block();
WebsiteModel result = crawlerBatchService.getWebsites(
seedWebsite,
null,
new URI(urlString),
0
).blockLast();
if (result != null)
{
putItemResultMono(urlString, EStatus.COMPLETED, result.getTitle(), result).block();
}
}
示例3: receiveMessage
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
@JmsListener(destination = Queue.EMAIL_QUEUE, containerFactory = "jmsContainerFactory")
public void receiveMessage(Message message) {
if (message instanceof ObjectMessage) {
ObjectMessage objectMessage = (ObjectMessage) message;
try {
if (objectMessage.getObject() instanceof EmailJmsMessage) {
try {
EmailJmsMessage emailJmsMessage = (EmailJmsMessage) objectMessage.getObject();
emailMessage.sendEmail(emailJmsMessage.getHtml(), emailJmsMessage.getAttachments(),
emailJmsMessage.getRecipient(), emailJmsMessage.getSubject());
} catch (Exception e) {
logger.error("Email messaging exception", e);
}
}
} catch (JMSException ex) {
logger.error("JMSException thrown during Email JMS message acknowledgment:", ex);
}
} else {
logger.error("JMS: not an object message - nothing to do");
}
}
示例4: processMessage
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
/**
* Processes a JMS message.
*
* @param payload the message payload.
* @param allHeaders the JMS headers.
*/
@JmsListener(id = HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING,
containerFactory = "jmsListenerContainerFactory", destination = HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING)
public void processMessage(String payload, @Headers Map<Object, Object> allHeaders)
{
LOGGER.info("JMS message received from the queue. jmsQueueName=\"{}\" jmsMessageHeaders=\"{}\" jmsMessagePayload={}",
HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING, allHeaders, payload);
// Process the message as S3 notification.
boolean messageProcessed = processS3Notification(payload);
// If message is not processed as S3 notification, then process it as ESB system monitor message.
if (!messageProcessed)
{
messageProcessed = processEsbSystemMonitorMessage(payload);
}
if (!messageProcessed)
{
// The message was not processed, log the error.
LOGGER.error("Failed to process message from the JMS queue. jmsQueueName=\"{}\" jmsMessagePayload={}",
HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING, payload);
}
}
示例5: echo
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
@JmsListener(destination = "testQueue")
@SendTo("anotherQueue")
public Message<String> echo(String input, JmsMessageHeaderAccessor headerAccessor) {
logger.info("Sending back: " + input + " (messageId=" + headerAccessor.getMessageId() + ")");
return MessageBuilder.withPayload(input)
.setHeader("myCustomHeader", "foo")
.setHeader(JmsHeaders.TYPE, "myJmsType")
.build();
}
示例6: onAccountBalance
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
@JmsListener(destination = "account_balance")
public void onAccountBalance(String message) {
try {
JSONObject jsonObject = new JSONObject(message);
JSONObject result = jsonObject.getJSONObject("result");
JSONArray lines = result.getJSONArray("lines");
Date now = Calendar.getInstance().getTime();
for (int i = 0; i < lines.length(); i++) {
JSONObject line = lines.getJSONObject(i);
AccountBalance ab = new AccountBalance();
ab.setAccount(line.optString("account"));
ab.setBalance(new BigDecimal(line.getDouble("balance")));
ab.setCreatedAt(now);
ab.setCurrency(line.optString(("currency")));
ab.setLimit_balance(new BigDecimal(line.getDouble("limit")));
ab.setLimit_peer(new BigDecimal(line.getDouble("limit_peer")));
ab.setQuality_in(new BigDecimal(line.getDouble("quality_in")));
ab.setQuality_out(new BigDecimal(line.getDouble("quality_out")));
accountBalanceRepository.save(ab);
}
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
}
示例7: onMessage
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
@JmsListener(destination = "new.project.topic", containerFactory = "myFactory")
public void onMessage(String message) {
try {
projectBurndownService.newProject(ProjectBurndown.fromJSON(message));
} finally {
tracer.activeSpan().close();
}
}
開發者ID:Estafet-LTD,項目名稱:estafet-microservices-scrum-api-project-burndown,代碼行數:9,代碼來源:NewProjectConsumer.java
示例8: onMessage
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
@JmsListener(destination = "new.sprint.topic", containerFactory = "myFactory")
public void onMessage(String message) {
try {
projectBurndownService.updateBurndown(ProjectBurndownSprint.fromJSON(message));
} finally {
tracer.activeSpan().close();
}
}
開發者ID:Estafet-LTD,項目名稱:estafet-microservices-scrum-api-project-burndown,代碼行數:9,代碼來源:NewSprintConsumer.java
示例9: onMessage
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
@JmsListener(destination = "update.sprint.topic", containerFactory = "myFactory")
public void onMessage(String message) {
try {
projectBurndownService.updateBurndown(ProjectBurndownSprint.fromJSON(message));
} finally {
tracer.activeSpan().close();
}
}
開發者ID:Estafet-LTD,項目名稱:estafet-microservices-scrum-api-project-burndown,代碼行數:9,代碼來源:UpdatedSprintConsumer.java
示例10: onMessage
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
@JmsListener(destination = "new.story.topic", containerFactory = "myFactory")
public void onMessage(String message) {
try {
projectBurndownService.updateBurndown(Story.fromJSON(message));
} finally {
tracer.activeSpan().close();
}
}
開發者ID:Estafet-LTD,項目名稱:estafet-microservices-scrum-api-project-burndown,代碼行數:9,代碼來源:NewStoryConsumer.java
示例11: onMessage
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
@JmsListener(destination = "update.story.topic", containerFactory = "myFactory")
public void onMessage(String message) {
try {
projectBurndownService.updateBurndown(Story.fromJSON(message));
} finally {
tracer.activeSpan().close();
}
}
開發者ID:Estafet-LTD,項目名稱:estafet-microservices-scrum-api-project-burndown,代碼行數:9,代碼來源:UpdatedStoryConsumer.java
示例12: cancel
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
/**
* Cancels processing of the batch by updating its state to CANCELED.
*
* @param batchId id of the batch
*/
@Transactional
@JmsListener(destination = "cancel")
public void cancel(String batchId) {
Batch batch = batchStore.find(batchId);
notNull(batch, () -> new MissingObject(Batch.class, batchId));
batch.setState(BatchState.CANCELED);
batchStore.save(batch);
log.info("Batch " + batch.getId() + " has been canceled. The batch state changed to CANCELED.");
}
示例13: processSip
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
/**
* Receives JMS message from the coordinator and does the following:
* <p>
* 1. retrieves the specified batch from database, if the batch has got more than 1/2 failures in processing of its SIPs,
* method stops evaluation, otherwise continues with the next step
* <p>
* 2. checks that the batch state is PROCESSING, updates the SIP with state PROCESSING and starts BPM process for the SIP
*
* @param dto object with the batch id and sip id
* @throws InterruptedException
*/
@Async
@JmsListener(destination = "worker")
public void processSip(CoordinatorDto dto) throws InterruptedException {
String sipId = dto.getSipId();
String batchId = dto.getBatchId();
log.info("Message received at worker. Batch ID: " + batchId + ", SIP ID: " + sipId);
Batch batch = batchStore.find(batchId);
Utils.notNull(batch, () -> new MissingObject(Batch.class, batchId));
Utils.in(sipId, batch.getIds(), () -> new ForbiddenObject(Batch.class, batchId));
if (tooManyFailedSips(batch)) {
template.convertAndSend("cancel", batch.getId());
log.info("Processing of batch " + batchId + " stopped because of too many SIP failures.");
return;
}
if (batch.getState() == BatchState.PROCESSING) {
Sip sip = sipStore.find(sipId);
sip.setState(SipState.PROCESSING);
sipStore.save(sip);
log.info("State of SIP " + sip.getId() + " changed to PROCESSING.");
runtimeService.startProcessInstanceByKey("Ingest", asMap("sipId", sipId, "batchId", batchId))
.getProcessInstanceId();
} else {
log.info("Cannot proccess SIP " + sipId + " because the batch " + batchId + " is in the state " + batch.getState() + ".");
}
}
示例14: onMessageSecond
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
@JmsListener(destination = "TEST.SECOND")
public void onMessageSecond(String message) {
System.out.println(message);
try (Scope scope = mockTracer.buildSpan("on message").startActive(true)) {
scope.span().setTag("test", "test");
}
}
示例15: receiveQueue
import org.springframework.jms.annotation.JmsListener; //導入依賴的package包/類
@JmsListener(destination = "account",containerFactory = "queueListenerContainerFactory")
public void receiveQueue(byte[] message) {
LOGGER.info("=========扣減賬戶信息接收到Myth框架傳入的信息==========");
final Boolean success = mythMqReceiveService.processMessage(message);
if(success){
//消費成功,消息出隊列,否則不消費
}
}