Search in sources :

Example 41 with JMSProducer

use of javax.jms.JMSProducer in project wildfly by wildfly.

the class JMSSender method sendMessage.

@TransactionAttribute(NOT_SUPPORTED)
public void sendMessage(String payload) {
    try (JMSContext context = connectionFactory.createContext()) {
        JMSProducer producer = context.createProducer();
        producer.send(queue, payload);
    }
}
Also used : JMSProducer(javax.jms.JMSProducer) JMSContext(javax.jms.JMSContext) TransactionAttribute(javax.ejb.TransactionAttribute)

Example 42 with JMSProducer

use of javax.jms.JMSProducer in project wildfly by wildfly.

the class AppScopedBean method sendMessage.

public void sendMessage() {
    JMSProducer producer = context.createProducer();
    producer.send(queue, "a message");
}
Also used : JMSProducer(javax.jms.JMSProducer)

Example 43 with JMSProducer

use of javax.jms.JMSProducer in project ART-TIME by Artezio.

the class MailingEngine method sendOverJms.

private void sendOverJms(Mail mail) {
    ObjectMessage objectMessage = jmsContext.createObjectMessage(mail);
    JMSProducer jmsProducer = jmsContext.createProducer();
    jmsProducer.send(jmsQueue, objectMessage);
}
Also used : ObjectMessage(javax.jms.ObjectMessage) JMSProducer(javax.jms.JMSProducer)

Example 44 with JMSProducer

use of javax.jms.JMSProducer in project qpid-broker-j by apache.

the class DeliveryDelayTest method testDeliveryDelay.

@Test
public void testDeliveryDelay() throws Exception {
    try (JMSContext context = getConnectionBuilder().buildConnectionFactory().createContext()) {
        Destination queue = createQueue(context, BrokerAdmin.TEST_QUEUE_NAME, true);
        final AtomicLong messageReceiptTime = new AtomicLong();
        final CountDownLatch receivedLatch = new CountDownLatch(1);
        context.createConsumer(queue).setMessageListener(message -> {
            messageReceiptTime.set(System.currentTimeMillis());
            receivedLatch.countDown();
        });
        JMSProducer producer = context.createProducer().setDeliveryDelay(DELIVERY_DELAY);
        final long messageSentTime = System.currentTimeMillis();
        producer.send(queue, "delayed message");
        final boolean messageArrived = receivedLatch.await(DELIVERY_DELAY * 3, TimeUnit.MILLISECONDS);
        assertTrue("Delayed message did not arrive within expected period", messageArrived);
        final long actualDelay = messageReceiptTime.get() - messageSentTime;
        assertTrue(String.format("Message was not delayed by sufficient time (%d). Actual delay (%d)", DELIVERY_DELAY, actualDelay), actualDelay >= DELIVERY_DELAY);
    }
}
Also used : Destination(javax.jms.Destination) AtomicLong(java.util.concurrent.atomic.AtomicLong) JMSProducer(javax.jms.JMSProducer) CountDownLatch(java.util.concurrent.CountDownLatch) JMSContext(javax.jms.JMSContext) Test(org.junit.Test)

Example 45 with JMSProducer

use of javax.jms.JMSProducer in project eap-additional-testsuite by jboss-set.

the class AppScopedBean method sendMessage.

public void sendMessage() {
    JMSProducer producer = context.createProducer();
    producer.send(queue, "a message");
}
Also used : JMSProducer(javax.jms.JMSProducer)

Aggregations

JMSProducer (javax.jms.JMSProducer)46 Test (org.junit.Test)36 JMSContext (javax.jms.JMSContext)27 TextMessage (javax.jms.TextMessage)24 JMSConsumer (javax.jms.JMSConsumer)23 ConnectionFactory (javax.jms.ConnectionFactory)11 Message (javax.jms.Message)11 BytesMessage (javax.jms.BytesMessage)8 Queue (javax.jms.Queue)8 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)8 Destination (javax.jms.Destination)7 CountDownLatch (java.util.concurrent.CountDownLatch)6 StreamMessage (javax.jms.StreamMessage)6 JMSException (javax.jms.JMSException)5 InitialContext (javax.naming.InitialContext)5 JMSRuntimeException (javax.jms.JMSRuntimeException)4 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)4 Topic (javax.jms.Topic)3 Path (java.nio.file.Path)2 CompletionListener (javax.jms.CompletionListener)2