Search in sources :

Example 11 with Queue

use of jakarta.jms.Queue in project spring-framework by spring-projects.

the class MessagingMessageListenerAdapterTests method replyPayloadToQueue.

@Test
public void replyPayloadToQueue() throws JMSException {
    Session session = mock(Session.class);
    Queue replyDestination = mock(Queue.class);
    given(session.createQueue("queueOut")).willReturn(replyDestination);
    MessageProducer messageProducer = mock(MessageProducer.class);
    TextMessage responseMessage = mock(TextMessage.class);
    given(session.createTextMessage("Response")).willReturn(responseMessage);
    given(session.createProducer(replyDestination)).willReturn(messageProducer);
    MessagingMessageListenerAdapter listener = getPayloadInstance("Response", "replyPayloadToQueue", Message.class);
    listener.onMessage(mock(jakarta.jms.Message.class), session);
    verify(session).createQueue("queueOut");
    verify(session).createTextMessage("Response");
    verify(messageProducer).send(responseMessage);
    verify(messageProducer).close();
}
Also used : StubTextMessage(org.springframework.jms.StubTextMessage) Message(org.springframework.messaging.Message) TextMessage(jakarta.jms.TextMessage) MessageProducer(jakarta.jms.MessageProducer) Queue(jakarta.jms.Queue) StubTextMessage(org.springframework.jms.StubTextMessage) TextMessage(jakarta.jms.TextMessage) Session(jakarta.jms.Session) Test(org.junit.jupiter.api.Test)

Example 12 with Queue

use of jakarta.jms.Queue in project spring-framework by spring-projects.

the class MessagingMessageListenerAdapterTests method replyWithFullQoS.

@Test
public void replyWithFullQoS() throws JMSException {
    Session session = mock(Session.class);
    Queue replyDestination = mock(Queue.class);
    given(session.createQueue("queueOut")).willReturn(replyDestination);
    MessageProducer messageProducer = mock(MessageProducer.class);
    TextMessage responseMessage = mock(TextMessage.class);
    given(session.createTextMessage("Response")).willReturn(responseMessage);
    given(session.createProducer(replyDestination)).willReturn(messageProducer);
    MessagingMessageListenerAdapter listener = getPayloadInstance("Response", "replyPayloadToQueue", Message.class);
    QosSettings settings = new QosSettings(DeliveryMode.NON_PERSISTENT, 6, 6000);
    listener.setResponseQosSettings(settings);
    listener.onMessage(mock(jakarta.jms.Message.class), session);
    verify(session).createQueue("queueOut");
    verify(session).createTextMessage("Response");
    verify(messageProducer).send(responseMessage, DeliveryMode.NON_PERSISTENT, 6, 6000);
    verify(messageProducer).close();
}
Also used : StubTextMessage(org.springframework.jms.StubTextMessage) Message(org.springframework.messaging.Message) TextMessage(jakarta.jms.TextMessage) QosSettings(org.springframework.jms.support.QosSettings) MessageProducer(jakarta.jms.MessageProducer) Queue(jakarta.jms.Queue) StubTextMessage(org.springframework.jms.StubTextMessage) TextMessage(jakarta.jms.TextMessage) Session(jakarta.jms.Session) Test(org.junit.jupiter.api.Test)

Aggregations

Queue (jakarta.jms.Queue)12 Session (jakarta.jms.Session)10 Test (org.junit.jupiter.api.Test)10 TextMessage (jakarta.jms.TextMessage)9 MessageProducer (jakarta.jms.MessageProducer)7 QueueSession (jakarta.jms.QueueSession)6 StubTextMessage (org.springframework.jms.StubTextMessage)5 Message (org.springframework.messaging.Message)5 BytesMessage (jakarta.jms.BytesMessage)4 Message (jakarta.jms.Message)4 ObjectMessage (jakarta.jms.ObjectMessage)4 QueueSender (jakarta.jms.QueueSender)2 TopicSession (jakarta.jms.TopicSession)2 StubQueue (org.springframework.jms.StubQueue)2 QosSettings (org.springframework.jms.support.QosSettings)2 JMSException (jakarta.jms.JMSException)1 QueueBrowser (jakarta.jms.QueueBrowser)1 TemporaryQueue (jakarta.jms.TemporaryQueue)1 MappingJackson2MessageConverter (org.springframework.jms.support.converter.MappingJackson2MessageConverter)1 Nullable (org.springframework.lang.Nullable)1