@MessageDriven(name = "VertxMonitor", messageListenerInterface = VertxListener.class, activationConfig = { @ActivationConfigProperty(propertyName = "address", propertyValue = "inbound-address"), }) public class VertxMonitor implements VertxListener {
/** * * @author Steve Millidge (Payara Foundation) */ @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "nameSpace", propertyValue = "${ENV=nameSpace}"), @ActivationConfigProperty(propertyName = "sasKeyName", propertyValue = "RootManageSharedAccessKey"), @ActivationConfigProperty(propertyName = "sasKey", propertyValue = "${ENV=sasKey}"), @ActivationConfigProperty(propertyName = "queueName", propertyValue = "testq") }) public class AzureSBMDB implements AzureSBListener { @OnAzureSBMessage public void receiveMessage(IMessage message) { System.out.println("Received Message " + new String(message.getBody())); } }
@MessageDriven(name = "testmdb", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "TESTQ"), @ActivationConfigProperty(propertyName = "resourceAdapter", propertyValue = "activemq-rar-5.14.5") }) public class ReceiveMessage implements MessageListener { public ReceiveMessage() { } @Override public void onMessage(Message message) { System.out.println("Got message " + message); } }
@ActivationConfigProperty(propertyName = "clientId", propertyValue = "testClient"), @ActivationConfigProperty(propertyName = "groupIdConfig", propertyValue = "testGroup"), @ActivationConfigProperty(propertyName = "topics", propertyValue = "test,test2"), @ActivationConfigProperty(propertyName = "bootstrapServersConfig", propertyValue = "localhost:9092"), @ActivationConfigProperty(propertyName = "autoCommitInterval", propertyValue = "100"), @ActivationConfigProperty(propertyName = "retryBackoff", propertyValue = "1000"), @ActivationConfigProperty(propertyName = "keyDeserializer", propertyValue = "org.apache.kafka.common.serialization.StringDeserializer"), @ActivationConfigProperty(propertyName = "valueDeserializer", propertyValue = "org.apache.kafka.common.serialization.StringDeserializer"), @ActivationConfigProperty(propertyName = "pollInterval", propertyValue = "3000"), }) public class KafkaMDB implements KafkaListener {
/** * * @author Steve Millidge (Payara Foundation) */ @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "awsAccessKeyId", propertyValue = "${ENV=accessKey}"), @ActivationConfigProperty(propertyName = "awsSecretKey", propertyValue = "${ENV=secretKey}"), @ActivationConfigProperty(propertyName = "queueURL", propertyValue = "${ENV=queueURL}"), @ActivationConfigProperty(propertyName = "pollInterval", propertyValue = "1000"), @ActivationConfigProperty(propertyName = "region", propertyValue = "eu-west-2") }) public class ReceiveSQSMessage implements AmazonSQSListener { @OnSQSMessage public void receiveMessage(Message message) { System.out.println("Got message " + message.getBody()); Map<String,MessageAttributeValue> mattrs = message.getMessageAttributes(); for (String key : mattrs.keySet()) { System.out.println("Got Message attribute " + key + "," + mattrs.get(key).getStringValue()); } Map<String,String> attrs = message.getAttributes(); for (String key : attrs.keySet()) { System.out.println("Got attribute " + key + "," + attrs.get(key)); } } }
/** * * @author Mike Croft */ @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jms/notifierQueue"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "notifierQueue"), }) public class NotificationConsumer implements MessageListener { @Override public void onMessage(Message message) { try { System.out.println("Message received: " + message.getBody(String.class)); } catch (JMSException ex) { Logger.getLogger(NotificationConsumer.class.getName()).log(Level.SEVERE, null, ex); } } }
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "OrderQueue") }) public class OrderRecvMDB implements MessageListener { /* * Process a message. * * @param message The message to process. */ public void onMessage(Message message) { TextMessage textMessage = (TextMessage) message; try { System.out.println("(mdb) Order Received \n" + textMessage.getText()); } catch (JMSException e) { e.printStackTrace(); } } }
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/queue/test")}) public class ExampleMDB implements MessageListener { @Override public void onMessage(Message message) { if (message instanceof TextMessage) { try { System.out.println("----------------"); System.out.println("Received: " + ((TextMessage) message).getText()); System.out.println("----------------"); } catch (JMSException e) { e.printStackTrace(); } } else { System.out.println("----------------"); System.out.println("Received: " + message); System.out.println("----------------"); } } }
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/queue/test")}) public class ExampleQueueMDB implements MessageListener { @Override public void onMessage(Message message) { if (message instanceof TextMessage) { try { System.out.println("----------------"); System.out.println("Received: " + ((TextMessage) message).getText()); System.out.println("----------------"); } catch (JMSException e) { e.printStackTrace(); } } else { System.out.println("----------------"); System.out.println("Received: " + message); System.out.println("----------------"); } } }
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/topic/test")}) public class ExampleTopicMDB implements MessageListener { @Override public void onMessage(Message message) { if (message instanceof TextMessage) { try { System.out.println("----------------"); System.out.println("Received: " + ((TextMessage) message).getText()); System.out.println("----------------"); } catch (JMSException e) { e.printStackTrace(); } } else { System.out.println("----------------"); System.out.println("Received: " + message); System.out.println("----------------"); } } }
/** * * @author Steve Millidge (Payara Foundation) */ @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "topicFilter", propertyValue = "test") }) public class MQTTReceiveMessage implements MQTTListener { @OnMQTTMessage public void messageArrived(String topic, MqttMessage message) { Logger.getAnonymousLogger().info("Received message on topic " + topic + " " + new String(message.getPayload())); } }
@MessageDriven(activationConfig = { @ActivationConfigProperty( propertyName = "destinationType", propertyValue = "javax.jms.Topic"), @ActivationConfigProperty( propertyName = "destination", propertyValue = "exampleTopic") }) @Interceptors(TraceeMessageListener.class) public class MessageTopicListener implements MessageListener { private static final Logger LOG = LoggerFactory.getLogger(MessageTopicListener.class); @Override public void onMessage(Message message) { LOG.info("I just received the message \"{}\" on jms/exampleTopic", message); } }
/** * * @author Steve Millidge (Payara Foundation) */ @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "topicFilter", propertyValue = "test") }) public class MQTTMDB implements MQTTListener { @OnMQTTMessage public void messageArrived(String topic, MqttMessage message) { System.out.println("Received message on topic " + topic + " " + new String(message.getPayload())); } }
@MessageDriven(activationConfig = { @ActivationConfigProperty( propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty( propertyName = "destination", propertyValue = "exampleQueue") }) @Interceptors(TraceeMessageListener.class) public class MessageQueueListener implements MessageListener { private static final Logger LOG = LoggerFactory.getLogger(MessageQueueListener.class); @Override public void onMessage(Message message) { LOG.info("I just received the message \"{}\" on jms/exampleQueue", message); } }
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "orderAmount < 3000") }) public class BillingMDB11 implements MessageListener {
@ActivationConfigProperty( propertyName = "destination", propertyValue = "queue/DLQ"), @ActivationConfigProperty( propertyName = "destinationType", propertyValue = "javax.jms.Queue") }) public class MessageEcho implements MessageListener
@ActivationConfigProperty( propertyName = "destination", propertyValue = "queue/DLQ"), @ActivationConfigProperty( propertyName = "destinationType", propertyValue = "javax.jms.Queue") }) public class MessageEcho implements MessageListener
/** * * @author Mike Croft */ @JMSDestinationDefinition( name="java:global/queue/simpleQ", interfaceName="javax.jms.Queue", destinationName = "simpleQ" ) @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:global/queue/simpleQ"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") }) public class MessageConsumer implements MessageListener { public MessageConsumer() { } @Override public void onMessage(Message message) { try { System.out.println("Message received: " + message.getBody(String.class)); } catch (JMSException ex) { Logger.getLogger(MessageConsumer.class.getName()).log(Level.SEVERE, null, ex); } } }
/** * @author Antonio Goncalves * APress Book - Beginning Java EE 7 with Glassfish 4 * http://www.apress.com/ * http://www.antoniogoncalves.org * -- */ @MessageDriven(mappedName = "jms/javaee7/Topic", activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "orderAmount > 1000") }) @JMSConnectionFactoryDefinition(name = "jms/javaee7/ConnectionFactory", className = "javax.jms.ConnectionFactory") @JMSDestinationDefinition(name = "jms/javaee7/Topic", className = "javax.jms.Topic", interfaceName = "javax.jms.Topic") public class ExpensiveOrderMDB implements MessageListener { // ====================================== // = Public Methods = // ====================================== public void onMessage(Message message) { try { OrderDTO order = message.getBody(OrderDTO.class); System.out.println("Expensive order received: " + order.toString()); } catch (JMSException e) { e.printStackTrace(); } } }
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = RegistrationMdb.DESTINATION_QUEUE) }) public class RegistrationMdb extends AbstractJMSHibernateSearchController implements MessageListener { public static final String DESTINATION_QUEUE = "jms/queue/hsearch"; @PersistenceUnit private EntityManagerFactory emf; @Override protected SearchIntegrator getSearchIntegrator() { return SearchIntegratorHelper.extractFromEntityManagerFactory( emf ); } }