org.springframework.jms.annotation.JmsListener Java Examples
The following examples show how to use
org.springframework.jms.annotation.JmsListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TrackerRuleEngineMessageManager.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
@JmsListener( destination = Topics.TRACKER_IMPORT_RULE_ENGINE_TOPIC_NAME, containerFactory = "jmsQueueListenerContainerFactory" ) public void consume( TextMessage message ) throws JMSException, IOException { TrackerSideEffectDataBundle bundle = toBundle( message ); if ( bundle == null ) { return; } JobConfiguration jobConfiguration = new JobConfiguration( "", JobType.TRACKER_IMPORT_RULE_ENGINE_JOB, bundle.getAccessedBy(), true ); bundle.setJobConfiguration( jobConfiguration ); TrackerRuleEngineThread notificationThread = trackerRuleEngineThreadObjectFactory.getObject(); notificationThread.setSideEffectDataBundle( bundle ); executeJob( notificationThread ); }
Example #2
Source File: MQConsumer.java From paas with Apache License 2.0 | 6 votes |
/** * 接收数据卷信息 * @author hf * @since 2018/7/13 17:08 */ @JmsListener(destination = "MQ_QUEUE_VOLUME") public void receiveVolume(String text) { if (StringUtils.isNotBlank(text)) { Task task = JsonUtils.jsonToObject(text, Task.class); Map<String, String> map = task.getData(); String userId = map.get("uid"); ResultVO resultVO = JsonUtils.jsonToObject(map.get("data"), ResultVO.class); String field = ID_PREFIX + userId; try { String sessionId = jedisClient.hget(key, field); if (StringUtils.isNotBlank(sessionId)) { webSocketServer.sendMessage(JsonUtils.objectToJson(resultVO), sessionId); } else { throw new Exception("session未找到"); } } catch (Exception e) { log.error("接收通知消息错误,错误位置:{},错误信息:{}", "MQConsumer.接收到消息()", e.getMessage()); } } }
Example #3
Source File: MQConsumer.java From paas with Apache License 2.0 | 6 votes |
/** * 接收通知信息 * @author hf * @since 2018/7/13 17:08 */ @JmsListener(destination = "MQ_QUEUE_NOTICE") public void receiveNotice(String text) { if (StringUtils.isNotBlank(text)) { Task task = JsonUtils.jsonToObject(text, Task.class); Map<String, String> map = task.getData(); String userId = map.get("uid"); ResultVO resultVO = JsonUtils.jsonToObject(map.get("data"), ResultVO.class); String field = ID_PREFIX + userId; try { String sessionId = jedisClient.hget(key, field); if (StringUtils.isNotBlank(sessionId)) { webSocketServer.sendMessage(JsonUtils.objectToJson(resultVO), sessionId); } else { throw new Exception("session未找到"); } } catch (Exception e) { log.error("接收通知消息错误,错误位置:{},错误信息:{}", "MQConsumer.receiveService()", e.getMessage()); } } }
Example #4
Source File: MQConsumer.java From paas with Apache License 2.0 | 6 votes |
/** * 接收服务信息 * @author hf * @since 2018/7/13 17:08 */ @JmsListener(destination = "MQ_QUEUE_SERVICE") public void receiveService(String text) { if (StringUtils.isNotBlank(text)) { Task task = JsonUtils.jsonToObject(text, Task.class); Map<String, String> map = task.getData(); String userId = map.get("uid"); ResultVO resultVO = JsonUtils.jsonToObject(map.get("data"), ResultVO.class); String field = ID_PREFIX + userId; try { String sessionId = jedisClient.hget(key, field); if (StringUtils.isNotBlank(sessionId)) { webSocketServer.sendMessage(JsonUtils.objectToJson(resultVO), sessionId); } else { throw new Exception("session未找到"); } } catch (Exception e) { log.error("接收服务消息错误,错误位置:{},错误信息:{}", "MQConsumer.receiveService()", e.getMessage()); } } }
Example #5
Source File: MQConsumer.java From paas with Apache License 2.0 | 6 votes |
/** * 接收HUB镜像信息 * @author jitwxs * @since 2018/7/9 17:08 */ @JmsListener(destination = "MQ_QUEUE_HUB_IMAGE") public void receiveHubImage(String text) { if (StringUtils.isNotBlank(text)) { Task task = JsonUtils.jsonToObject(text, Task.class); Map<String, String> map = task.getData(); String userId = map.get("uid"); String field = ID_PREFIX + userId; try { String sessionId = jedisClient.hget(key, field); if (StringUtils.isNotBlank(sessionId)) { webSocketServer.sendMessage(map.get("data"), sessionId); } else { throw new Exception("session未找到"); } } catch (Exception e) { log.error("接收HUB镜像消息错误,错误位置:{},错误信息:{}", "MQConsumer.receiveHubImage()", e.getMessage()); } } }
Example #6
Source File: ActiveMQReceiveMsgService.java From hdw-dubbo with Apache License 2.0 | 6 votes |
@JmsListener(destination = "ActiveMQ.Advisory.Connection", containerFactory = "topicJmsListenerContainerFactory", concurrency = "5-10") public void advisoryConnection(Message msg) { try { if (msg instanceof ActiveMQMessage) { ActiveMQMessage aMsg = (ActiveMQMessage) msg; if (aMsg.getDataStructure() instanceof ConnectionInfo) { ConnectionInfo connectionInfo = (ConnectionInfo) aMsg.getDataStructure(); log.info("连接信息:" + JacksonUtil.toJson(connectionInfo)); } else if (aMsg.getDataStructure() instanceof RemoveInfo) { RemoveInfo removeInfo = (RemoveInfo) aMsg.getDataStructure(); log.info("移除信息:" + JacksonUtil.toJson(removeInfo)); } } } catch (Exception e) { e.printStackTrace(); } }
Example #7
Source File: MQConsumer.java From paas with Apache License 2.0 | 6 votes |
/** * 接收系统镜像信息 * @author jitwxs * @since 2018/7/9 17:08 */ @JmsListener(destination = "MQ_QUEUE_SYS_IMAGE") public void receiveSysImage(String text) { if (StringUtils.isNotBlank(text)) { Task task = JsonUtils.jsonToObject(text, Task.class); Map<String, String> map = task.getData(); String userId = map.get("uid"); String field = ID_PREFIX + userId; try { String sessionId = jedisClient.hget(key, field); if (StringUtils.isNotBlank(sessionId)) { webSocketServer.sendMessage(map.get("data"), sessionId); } else { throw new Exception("session未找到"); } } catch (Exception e) { log.error("接收系统镜像消息错误,错误位置:{},错误信息:{}", "MQConsumer.receiveSysImage()", e.getMessage()); } } }
Example #8
Source File: MQConsumer.java From paas with Apache License 2.0 | 6 votes |
/** * 接收容器信息 * @author jitwxs * @since 2018/7/9 17:08 */ @JmsListener(destination = "MQ_QUEUE_CONTAINER") public void receiveContainer(String text) { if (StringUtils.isNotBlank(text)) { Task task = JsonUtils.jsonToObject(text, Task.class); Map<String, String> map = task.getData(); String userId = map.get("uid"); String field = ID_PREFIX + userId; try { String sessionId = jedisClient.hget(key, field); if (StringUtils.isNotBlank(sessionId)) { webSocketServer.sendMessage(map.get("data"), sessionId); } else { throw new Exception("session未找到"); } } catch (Exception e) { log.error("接收容器消息错误,错误位置:{},错误信息:{}", "MQConsumer.receiveContainer()", e.getMessage()); } } }
Example #9
Source File: MQConsumer.java From paas with Apache License 2.0 | 6 votes |
/** * 接收邮箱注册消息 * @author jitwxs * @since 2018/7/9 16:05 */ @JmsListener(destination = "MQ_QUEUE_REGISTER") public void receiveRegister(String text) { if(StringUtils.isNotBlank(text)){ Task task = JsonUtils.jsonToObject(text, Task.class); Map<String, String> map = task.getData(); String email = map.get("email"); log.info("验证未激活邮箱,目标邮箱:{}", email); SysLogin login = loginService.getByEmail(email); if(login != null && login.getHasFreeze()) { loginService.deleteById(login); } } }
Example #10
Source File: JMSMailComsumer.java From ElementVueSpringbootCodeTemplate with Apache License 2.0 | 6 votes |
@JmsListener(destination = JMSType.SEND_MAIL) public void sendMail(@Payload Object obj, @Headers MessageHeaders headers, Message message, Session session) { log.info("recived mail: {}", obj); System.out.println("-------------------------"); System.out.println("obj:" + obj); System.out.println("headers:" + headers); System.out.println("message:" + message); System.out.println("session:" + session); System.out.println("-------------------------"); if (obj instanceof MimeMessage) { mailSender.send((MimeMessage) obj); } else { mailSender.send((SimpleMailMessage) obj); } }
Example #11
Source File: Receiver.java From spring-jms with MIT License | 6 votes |
@JmsListener(destination = "${destination.order}") public void receiveOrder(String orderNumber, @Header(JmsHeaders.MESSAGE_ID) String messageId) { LOGGER.info("received OrderNumber='{}' with MessageId='{}'", orderNumber, messageId); LOGGER.info("sending Status='Accepted' with CorrelationId='{}'", messageId); jmsTemplate.send(statusDestination, messageCreator -> { TextMessage message = messageCreator.createTextMessage("Accepted"); message.setJMSCorrelationID(messageId); return message; }); }
Example #12
Source File: TrackerMessageManager.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
@JmsListener( destination = Topics.TRACKER_IMPORT_JOB_TOPIC_NAME, containerFactory = "jmsQueueListenerContainerFactory" ) public void consume( TextMessage message ) throws JMSException, JsonProcessingException { String payload = message.getText(); TrackerMessage trackerMessage = objectMapper.readValue( payload, TrackerMessage.class ); TrackerImportParams trackerImportParams = trackerMessage.getTrackerImportParams(); JobConfiguration jobConfiguration = new JobConfiguration( "", JobType.TRACKER_IMPORT_JOB, trackerImportParams.getUserId(), true ); jobConfiguration.setUid( trackerMessage.getUid() ); trackerImportParams.setJobConfiguration( jobConfiguration ); TrackerImportThread trackerImportThread = trackerImportThreadFactory.getObject(); trackerImportThread.setTrackerImportParams( trackerImportParams ); schedulingManager.executeJob( trackerImportThread ); }
Example #13
Source File: TrackerNotificationMessageManager.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
@JmsListener( destination = Topics.TRACKER_IMPORT_NOTIFICATION_TOPIC_NAME, containerFactory = "jmsQueueListenerContainerFactory" ) public void consume( TextMessage message ) throws JMSException, IOException { TrackerSideEffectDataBundle bundle = toBundle( message ); if ( bundle == null ) { return; } JobConfiguration jobConfiguration = new JobConfiguration( "", JobType.TRACKER_IMPORT_NOTIFICATION_JOB, bundle.getAccessedBy(), true ); bundle.setJobConfiguration( jobConfiguration ); TrackerNotificationThread notificationThread = trackerNotificationThreadObjectFactory.getObject(); notificationThread.setSideEffectDataBundle( bundle ); executeJob( notificationThread ); }
Example #14
Source File: SampleService.java From tutorial with MIT License | 5 votes |
/** * JmsListener注解可以声明这个方法用于接收JMS(ActiveMQ)消息队列里的消息 * @param message */ @JmsListener(destination="addtvseriesevents") public void receiveMessage(String message) { if(log.isTraceEnabled()) { log.trace("Received <" + message + ">"); } }
Example #15
Source File: ActiveMQReceiveMsgService.java From hdw-dubbo with Apache License 2.0 | 5 votes |
@JmsListener(destination = "ActiveMQ.Advisory.Producer.Queue.test", containerFactory = "topicJmsListenerContainerFactory", concurrency = "5-10") public void advisoryProducerQueueTest(Message msg) { try { if (msg instanceof ActiveMQMessage) { ActiveMQMessage aMsg = (ActiveMQMessage) msg; if (aMsg.getDataStructure() instanceof ProducerInfo) { ProducerInfo producerInfo = (ProducerInfo) aMsg.getDataStructure(); log.info("sensorDataQueue生产者信息:" + JacksonUtil.toJson(producerInfo)); } } } catch (Exception e) { e.printStackTrace(); } }
Example #16
Source File: Listener.java From mq-jms-spring with Apache License 2.0 | 5 votes |
@JmsListener(destination = Application.qName) public void receiveMessage(String msg) { infinityWarning(); System.out.println(); System.out.println("========================================"); System.out.println("Received message is: " + msg); System.out.println("========================================"); }
Example #17
Source File: UserReceiver.java From Spring with Apache License 2.0 | 5 votes |
@JmsListener(destination = "userQueue", containerFactory = "connectionFactory") public void receiveMessage(User receivedUser, Message message) { log.info(" >> Original received message: " + message); log.info(" >> Received user: " + receivedUser); confirmationSender.sendMessage(new Confirmation(id.incrementAndGet(), "User " + receivedUser.getEmail() + " received.")); }
Example #18
Source File: MqListener.java From MyBlog with Apache License 2.0 | 5 votes |
@JmsListener(destination = "com.lfz.queue.mail", containerFactory = "queueFactory") public void onQueueMessage(String username) { try { log.info("new user:{}", username); myMailSender.send(username); } catch (Exception e) { log.error("on queue message error", e); } }
Example #19
Source File: ActiveMQReceiveMsgService.java From hdw-dubbo with Apache License 2.0 | 5 votes |
@JmsListener(destination = "ActiveMQ.Advisory.Consumer.Queue.test", containerFactory = "topicJmsListenerContainerFactory", concurrency = "5-10") public void advisoryConsumerQueueTest3(Message msg) { try { if (msg instanceof ActiveMQMessage) { ActiveMQMessage aMsg = (ActiveMQMessage) msg; if (aMsg.getDataStructure() instanceof ConsumerInfo) { ConsumerInfo consumerInfo = (ConsumerInfo) aMsg.getDataStructure(); log.info("sensorDataQueue消费者信息:" + JacksonUtil.toJson(consumerInfo)); } } } catch (Exception e) { e.printStackTrace(); } }
Example #20
Source File: JndiDemoApplication.java From solace-jms-spring-boot with Apache License 2.0 | 5 votes |
@JmsListener(destination = "${solace.jms.demoConsumerQueueJndiName}", containerFactory = "cFactory") public void processMsg(Message<?> msg) { StringBuffer msgAsStr = new StringBuffer("============= Received \nHeaders:"); MessageHeaders hdrs = msg.getHeaders(); msgAsStr.append("\nUUID: " + hdrs.getId()); msgAsStr.append("\nTimestamp: " + hdrs.getTimestamp()); Iterator<String> keyIter = hdrs.keySet().iterator(); while (keyIter.hasNext()) { String key = keyIter.next(); msgAsStr.append("\n" + key + ": " + hdrs.get(key)); } msgAsStr.append("\nPayload: " + msg.getPayload()); logger.info(msgAsStr.toString()); }
Example #21
Source File: SpringSecKillMessageSubscriber.java From seckill with Apache License 2.0 | 5 votes |
@Override @JmsListener(destination = "seckill", containerFactory = "containerFactory") public void subscribeMessage(String messageContent) { logger.info("receive message : {}", messageContent); EventMessageDto message = eventFormat.getFormat().deserialize(messageContent, EventMessageDto.class); SecKillEvent event = eventFormat.fromMessage(message); eventFactories.get(event.getType()).accept(event); }
Example #22
Source File: MqListener.java From MyBlog with Apache License 2.0 | 5 votes |
@JmsListener(destination = "com.lfz.topic.ws", containerFactory = "topicFactory") public void onTopicMessage(String message) { try { wsHandler.sendAllUser(message); } catch (Exception e) { log.error("on topic message error", e); } }
Example #23
Source File: ActivemqConsumer.java From myth with Apache License 2.0 | 5 votes |
@JmsListener(destination = "account",containerFactory = "queueListenerContainerFactory") public void receiveQueue(byte[] message) { LOGGER.info("=========扣减账户信息接收到Myth框架传入的信息=========="); final Boolean success = mythMqReceiveService.processMessage(message); if(success){ //消费成功,消息出队列,否则不消费 } }
Example #24
Source File: ActivemqConsumer.java From myth with Apache License 2.0 | 5 votes |
/** * Receive queue. * * @param message the message */ @JmsListener(destination = "inventory", containerFactory = "queueListenerContainerFactory") public void receiveQueue(byte[] message) { LOGGER.info("=========motan扣减库存接收到Myth框架传入的信息=========="); mythMqReceiveService.processMessage(message); }
Example #25
Source File: ActivemqConsumer.java From myth with Apache License 2.0 | 5 votes |
@JmsListener(destination = "account",containerFactory = "queueListenerContainerFactory") public void receiveQueue(byte[] message) { LOGGER.info("=========扣减账户信息接收到Myth框架传入的信息=========="); final Boolean success = mythMqReceiveService.processMessage(message); if(success){ //消费成功,消息出队列,否则不消费 } }
Example #26
Source File: ActivemqConsumer.java From myth with Apache License 2.0 | 5 votes |
/** * Receive queue. * * @param message the message */ @JmsListener(destination = "account",containerFactory = "queueListenerContainerFactory") public void receiveQueue(byte[] message) { LOGGER.info("=========扣减账户信息接收到Myth框架传入的信息=========="); final Boolean success = mythMqReceiveService.processMessage(message); if(success){ //消费成功,消息出队列,否则不消费 } }
Example #27
Source File: ActivemqConsumer.java From myth with Apache License 2.0 | 5 votes |
/** * Receive queue. * * @param message the message */ @JmsListener(destination = "inventory", containerFactory = "queueListenerContainerFactory") public void receiveQueue(byte[] message) { LOGGER.info("=========扣减库存接收到Myth框架传入的信息=========="); mythMqReceiveService.processMessage(message); }
Example #28
Source File: MessageConsumer.java From ditto-examples with Eclipse Public License 2.0 | 5 votes |
@JmsListener(destination = "dittooutbound/Subscriptions/fromditto", containerFactory = "myFactory") public void processDittoMessage(final String message) { final JsonValue jsonValue = JsonFactory.readFrom(message); final Adaptable adaptable = ProtocolFactory.jsonifiableAdaptableFromJson(jsonValue.asObject()); final Signal<?> actual = DITTO_PROTOCOL_ADAPTER.fromAdaptable(adaptable); System.out.println("Got signal from Ditto: " + actual); }
Example #29
Source File: OrderReceiver.java From spring-jms with MIT License | 5 votes |
@JmsListener(destination = "${destination.order}", containerFactory = "orderDefaultJmsListenerContainerFactory") public void receiveOrder(String order) { LOGGER.info("received order='{}'", order); jmsTemplate.convertAndSend(status1Destination, "Accepted"); jmsTemplate.convertAndSend(status2Destination, "Accepted"); }
Example #30
Source File: BookService.java From spring-cloud-contract with Apache License 2.0 | 5 votes |
/** * Scenario for "should generate tests triggered by a method": client side: must have * a possibility to "trigger" sending of a message to the given messageFrom server * side: will run the method and await upon receiving message on the output * messageFrom. Method triggers sending a message to a source */ @JmsListener(destination = "input2") public void returnBook() { BookReturned bookReturned = new BookReturned("foo"); jmsTemplate.convertAndSend("output2", "{\"bookName\":\"foo\"}", message -> { message.setStringProperty("BOOK-NAME", bookReturned.bookName); return message; }); }