當前位置: 首頁>>代碼示例>>Java>>正文


Java JmsListener類代碼示例

本文整理匯總了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);
}
 
開發者ID:jaschenk,項目名稱:Your-Microservice,代碼行數:30,代碼來源:EntityEventHistoryMessageListener.java

示例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();
    }
}
 
開發者ID:hafidsousa,項目名稱:webcrawler,代碼行數:24,代碼來源:CrawlerBatchTask.java

示例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");
    }
}
 
開發者ID:filipcynarski,項目名稱:EMailSenderService,代碼行數:22,代碼來源:EmailConsumer.java

示例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);
    }
}
 
開發者ID:FINRAOS,項目名稱:herd,代碼行數:30,代碼來源:HerdJmsMessageListener.java

示例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();
}
 
開發者ID:snicoll,項目名稱:scratches,代碼行數:10,代碼來源:DemoService.java

示例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);
	}
}
 
開發者ID:mileschet,項目名稱:ripple-marketmaker,代碼行數:26,代碼來源:RippleMessageStoreListener.java

示例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.");
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:18,代碼來源:CoordinatorService.java

示例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() + ".");
    }
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:46,代碼來源:WorkerService.java

示例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");
  }
}
 
開發者ID:opentracing-contrib,項目名稱:java-jms,代碼行數:9,代碼來源:Receiver.java

示例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){
        //消費成功,消息出隊列,否則不消費
    }
}
 
開發者ID:yu199195,項目名稱:myth,代碼行數:9,代碼來源:ActivemqConsumer.java


注:本文中的org.springframework.jms.annotation.JmsListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。