javax.jms.Message.setJMSReplyTo()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(309)

本文整理了Java中javax.jms.Message.setJMSReplyTo()方法的一些代码示例,展示了Message.setJMSReplyTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setJMSReplyTo()方法的具体详情如下:
包路径:javax.jms.Message
类名称:Message
方法名:setJMSReplyTo

Message.setJMSReplyTo介绍

[英]Sets the Destination object to which a reply to this message should be sent.

The JMSReplyTo header field contains the destination where a reply to the current message should be sent. If it is null, no reply is expected. The destination may be either a Queue object or a Topic object.

Messages sent with a null JMSReplyTo value may be a notification of some event, or they may just be some data the sender thinks is of interest.

Messages with a JMSReplyTo value typically expect a response. A response is optional; it is up to the client to decide. These messages are called requests. A message sent in response to a request is called a reply.

In some cases a client may wish to match a request it sent earlier with a reply it has just received. The client can use the JMSCorrelationID header field for this purpose.
[中]设置应向其发送对此消息的答复的目标对象。
JMSReplyTo标头字段包含应在其中发送对当前消息的答复的目的地。如果为空,则不需要回复。目标可以是队列对象或主题对象。
使用null JMSReplyTo值发送的消息可能是某个事件的通知,也可能只是发送者认为感兴趣的某个数据。
具有JMSReplyTo值的消息通常需要响应。响应是可选的;由客户决定。这些消息称为请求。响应请求而发送的消息称为回复。
在某些情况下,客户机可能希望将其先前发送的请求与刚刚收到的答复相匹配。客户机可以使用JMSCOrrationId头字段来实现此目的。

代码示例

代码示例来源:origin: apache/activemq

  1. /**
  2. * Convert a foreign JMS Message to a native ActiveMQ Message - Inbound or
  3. * visa-versa outbound. If the replyTo Destination instance is not null
  4. * then the Message is configured with the given replyTo value.
  5. *
  6. * @param message
  7. * The target message to convert to a native ActiveMQ message
  8. * @param replyTo
  9. * The replyTo Destination to set on the converted Message.
  10. *
  11. * @return the converted message
  12. * @throws JMSException
  13. */
  14. public Message convert(Message message, Destination replyTo) throws JMSException {
  15. Message msg = convert(message);
  16. if (replyTo != null) {
  17. msg.setJMSReplyTo(replyTo);
  18. } else {
  19. msg.setJMSReplyTo(null);
  20. }
  21. return msg;
  22. }

代码示例来源:origin: spring-projects/spring-framework

  1. producer = session.createProducer(queue);
  2. consumer = session.createConsumer(responseQueue);
  3. requestMessage.setJMSReplyTo(responseQueue);
  4. producer.send(requestMessage);
  5. long timeout = getReceiveTimeout();

代码示例来源:origin: spring-projects/spring-framework

  1. if (jmsReplyTo != null) {
  2. try {
  3. jmsMessage.setJMSReplyTo(jmsReplyTo);

代码示例来源:origin: spring-projects/spring-framework

  1. producer = session.createProducer(destination);
  2. consumer = session.createConsumer(responseQueue);
  3. requestMessage.setJMSReplyTo(responseQueue);
  4. if (logger.isDebugEnabled()) {
  5. logger.debug("Sending created message: " + requestMessage);

代码示例来源:origin: wildfly/wildfly

  1. /** Sends a request and waits for a reply. The temporary queue is used for
  2. * the {@code JMSReplyTo} destination, and only one reply per request
  3. * is expected.
  4. *
  5. * @param message the message to send
  6. *
  7. * @return the reply message
  8. *
  9. * @exception JMSException if the JMS provider fails to complete the
  10. * request due to some internal error.
  11. */
  12. public Message
  13. request(Message message) throws JMSException {
  14. message.setJMSReplyTo(tempQueue);
  15. sender.send(message);
  16. return (receiver.receive());
  17. }

代码示例来源:origin: wildfly/wildfly

  1. /** Sends a request and waits for a reply. The temporary topic is used for
  2. * the {@code JMSReplyTo} destination; the first reply is returned,
  3. * and any following replies are discarded.
  4. *
  5. * @param message the message to send
  6. *
  7. * @return the reply message
  8. *
  9. * @exception JMSException if the JMS provider fails to complete the
  10. * request due to some internal error.
  11. */
  12. public Message
  13. request(Message message) throws JMSException {
  14. message.setJMSReplyTo(tempTopic);
  15. publisher.publish(message);
  16. return(subscriber.receive());
  17. }

代码示例来源:origin: apache/nifi

  1. Destination destination = buildDestination(entry.getValue());
  2. if (destination != null) {
  3. message.setJMSReplyTo(destination);
  4. } else {
  5. logUnbuildableDestination(entry.getKey(), JmsHeaders.REPLY_TO);

代码示例来源:origin: spring-projects/spring-framework

  1. @Test
  2. public void jmsReplyToMappedToHeader() throws JMSException {
  3. Destination replyTo = new Destination() {};
  4. javax.jms.Message jmsMessage = new StubTextMessage();
  5. jmsMessage.setJMSReplyTo(replyTo);
  6. assertInboundHeader(jmsMessage, JmsHeaders.REPLY_TO, replyTo);
  7. }

代码示例来源:origin: wildfly/wildfly

  1. message.setJMSReplyTo(jmsHeaderReplyTo);

代码示例来源:origin: apache/nifi

  1. message.setJMSReplyTo(replyToQueue);

代码示例来源:origin: apache/activemq

  1. message.setJMSReplyTo(null);
  2. converted = jmsMessageConvertor.convert(message);

代码示例来源:origin: apache/activemq

  1. /**
  2. * Copies the standard JMS and user defined properties from the givem
  3. * message to the specified message
  4. *
  5. * @param fromMessage the message to take the properties from
  6. * @param toMessage the message to add the properties to
  7. * @throws JMSException
  8. */
  9. public static void copyProperties(Message fromMessage, Message toMessage) throws JMSException {
  10. toMessage.setJMSMessageID(fromMessage.getJMSMessageID());
  11. toMessage.setJMSCorrelationID(fromMessage.getJMSCorrelationID());
  12. toMessage.setJMSReplyTo(transformDestination(fromMessage.getJMSReplyTo()));
  13. toMessage.setJMSDestination(transformDestination(fromMessage.getJMSDestination()));
  14. toMessage.setJMSDeliveryMode(fromMessage.getJMSDeliveryMode());
  15. toMessage.setJMSRedelivered(fromMessage.getJMSRedelivered());
  16. toMessage.setJMSType(fromMessage.getJMSType());
  17. toMessage.setJMSExpiration(fromMessage.getJMSExpiration());
  18. toMessage.setJMSPriority(fromMessage.getJMSPriority());
  19. toMessage.setJMSTimestamp(fromMessage.getJMSTimestamp());
  20. Enumeration propertyNames = fromMessage.getPropertyNames();
  21. while (propertyNames.hasMoreElements()) {
  22. String name = propertyNames.nextElement().toString();
  23. Object obj = fromMessage.getObjectProperty(name);
  24. toMessage.setObjectProperty(name, obj);
  25. }
  26. }
  27. }

代码示例来源:origin: spring-projects/spring-integration

  1. if (jmsReplyTo instanceof Destination) {
  2. try {
  3. jmsMessage.setJMSReplyTo((Destination) jmsReplyTo);

代码示例来源:origin: org.apache.geronimo.specs/geronimo-jms_1.1_spec

  1. public Message request(Message message) throws JMSException {
  2. message.setJMSReplyTo(getTemporaryQueue());
  3. getSender().send(message);
  4. return getReceiver().receive();
  5. }

代码示例来源:origin: org.apache.geronimo.specs/geronimo-jms_1.1_spec

  1. public Message request(Message message) throws JMSException {
  2. message.setJMSReplyTo(getTemporaryTopic());
  3. getPublisher().publish(message);
  4. return (getSubscriber().receive());
  5. }

代码示例来源:origin: spring-projects/spring-integration

  1. jmsRequest.setJMSReplyTo(replyTo);
  2. connection.start();
  3. if (logger.isDebugEnabled()) {

代码示例来源:origin: spring-projects/spring-integration

  1. jmsRequest.setJMSReplyTo(replyTo);
  2. connection.start();
  3. if (logger.isDebugEnabled()) {

代码示例来源:origin: spring-projects/spring-integration

  1. @Test
  2. public void testJmsReplyToMappedToHeader() throws JMSException {
  3. Destination replyTo = new Destination() {
  4. };
  5. javax.jms.Message jmsMessage = new StubTextMessage();
  6. jmsMessage.setJMSReplyTo(replyTo);
  7. DefaultJmsHeaderMapper mapper = new DefaultJmsHeaderMapper();
  8. Map<String, Object> headers = mapper.toHeaders(jmsMessage);
  9. Object attrib = headers.get(JmsHeaders.REPLY_TO);
  10. assertNotNull(attrib);
  11. assertSame(replyTo, attrib);
  12. }

代码示例来源:origin: org.apache.openejb/javaee-api

  1. public Message request(Message message) throws JMSException {
  2. message.setJMSReplyTo(getTemporaryTopic());
  3. getPublisher().publish(message);
  4. return (getSubscriber().receive());
  5. }

代码示例来源:origin: apache/cxf

  1. private void postGetMessage(Session session, Destination destination, Destination replyTo)
  2. throws Exception {
  3. MessageProducer producer = session.createProducer(destination);
  4. Message message = session.createBytesMessage();
  5. message.setJMSReplyTo(replyTo);
  6. message.setStringProperty("Accept", "application/xml");
  7. message.setStringProperty(org.apache.cxf.message.Message.REQUEST_URI, "/bookstore/books/123");
  8. message.setStringProperty(org.apache.cxf.message.Message.HTTP_REQUEST_METHOD, "GET");
  9. producer.send(message);
  10. producer.close();
  11. }

相关文章