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

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

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

Message.getJMSRedelivered介绍

[英]Gets an indication of whether this message is being redelivered.

If a client receives a message with the JMSRedelivered field set, it is likely, but not guaranteed, that this message was delivered earlier but that its receipt was not acknowledged at that time.
[中]获取是否重新传递此消息的指示。
如果客户机接收到设置了JMSRedelived字段的消息,则很可能(但不能保证)该消息是在较早的时候传递的,但当时没有确认其接收。

代码示例

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

/**
 * If any of the arguments is a message, check the JMS re-delivered flag and
 * return it, otherwise return false to be on the safe side.
 * 
 * @see org.springframework.retry.interceptor.NewMethodArgumentsIdentifier#isNew(java.lang.Object[])
 */
@Override
public boolean isNew(Object[] args) {
  for (Object item : args) {
    if (item instanceof Message) {
      try {
        return !((Message) item).getJMSRedelivered();
      }
      catch (JMSException e) {
        throw new UnexpectedInputException("Could not extract message ID", e);
      }
    }
  }
  return false;
}

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

sbuf.append(m.getJMSRedelivered());

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

headers.put(JmsHeaders.REDELIVERED, jmsMessage.getJMSRedelivered());

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

private Map<String, String> extractMessageHeaders(final Message message) throws JMSException {
  final Map<String, String> messageHeaders = new HashMap<>();
  messageHeaders.put(JmsHeaders.DELIVERY_MODE, String.valueOf(message.getJMSDeliveryMode()));
  messageHeaders.put(JmsHeaders.EXPIRATION, String.valueOf(message.getJMSExpiration()));
  messageHeaders.put(JmsHeaders.PRIORITY, String.valueOf(message.getJMSPriority()));
  messageHeaders.put(JmsHeaders.REDELIVERED, String.valueOf(message.getJMSRedelivered()));
  messageHeaders.put(JmsHeaders.TIMESTAMP, String.valueOf(message.getJMSTimestamp()));
  messageHeaders.put(JmsHeaders.CORRELATION_ID, message.getJMSCorrelationID());
  messageHeaders.put(JmsHeaders.MESSAGE_ID, message.getJMSMessageID());
  messageHeaders.put(JmsHeaders.TYPE, message.getJMSType());
  String replyToDestinationName = this.retrieveDestinationName(message.getJMSReplyTo(), JmsHeaders.REPLY_TO);
  if (replyToDestinationName != null) {
    messageHeaders.put(JmsHeaders.REPLY_TO, replyToDestinationName);
  }
  String destinationName = this.retrieveDestinationName(message.getJMSDestination(), JmsHeaders.DESTINATION);
  if (destinationName != null) {
    messageHeaders.put(JmsHeaders.DESTINATION, destinationName);
  }
  return messageHeaders;
}

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

@Test
public void testIsNewForMessage() throws Exception {
  Message message = mock(Message.class);
  when(message.getJMSRedelivered()).thenReturn(true);
  assertEquals(false, newMethodArgumentsIdentifier.isNew(new Object[]{message}));
  
}

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

attributes.put(ATTRIBUTE_PREFIX + JMS_EXPIRATION, String.valueOf(message.getJMSExpiration()));
attributes.put(ATTRIBUTE_PREFIX + JMS_PRIORITY, String.valueOf(message.getJMSPriority()));
attributes.put(ATTRIBUTE_PREFIX + JMS_REDELIVERED, String.valueOf(message.getJMSRedelivered()));
attributes.put(ATTRIBUTE_PREFIX + JMS_TIMESTAMP, String.valueOf(message.getJMSTimestamp()));
return attributes;

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

/**
   * Copies the standard JMS and user defined properties from the givem
   * message to the specified message
   *
   * @param fromMessage the message to take the properties from
   * @param toMessage the message to add the properties to
   * @throws JMSException
   */
  public static void copyProperties(Message fromMessage, Message toMessage) throws JMSException {
    toMessage.setJMSMessageID(fromMessage.getJMSMessageID());
    toMessage.setJMSCorrelationID(fromMessage.getJMSCorrelationID());
    toMessage.setJMSReplyTo(transformDestination(fromMessage.getJMSReplyTo()));
    toMessage.setJMSDestination(transformDestination(fromMessage.getJMSDestination()));
    toMessage.setJMSDeliveryMode(fromMessage.getJMSDeliveryMode());
    toMessage.setJMSRedelivered(fromMessage.getJMSRedelivered());
    toMessage.setJMSType(fromMessage.getJMSType());
    toMessage.setJMSExpiration(fromMessage.getJMSExpiration());
    toMessage.setJMSPriority(fromMessage.getJMSPriority());
    toMessage.setJMSTimestamp(fromMessage.getJMSTimestamp());

    Enumeration propertyNames = fromMessage.getPropertyNames();

    while (propertyNames.hasMoreElements()) {
      String name = propertyNames.nextElement().toString();
      Object obj = fromMessage.getObjectProperty(name);
      toMessage.setObjectProperty(name, obj);
    }
  }
}

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

@Test
public void jmsReadOnlyPropertiesNotMapped() throws JMSException {
  Message<String> message = initBuilder()
      .setHeader(JmsHeaders.DESTINATION, new Destination() {})
      .setHeader(JmsHeaders.DELIVERY_MODE, DeliveryMode.NON_PERSISTENT)
      .setHeader(JmsHeaders.EXPIRATION, 1000L)
      .setHeader(JmsHeaders.MESSAGE_ID, "abc-123")
      .setHeader(JmsHeaders.PRIORITY, 9)
      .setHeader(JmsHeaders.REDELIVERED, true)
      .setHeader(JmsHeaders.TIMESTAMP, System.currentTimeMillis())
      .build();
  javax.jms.Message jmsMessage = new StubTextMessage();
  mapper.fromHeaders(message.getHeaders(), jmsMessage);
  assertNull(jmsMessage.getJMSDestination());
  assertEquals(DeliveryMode.PERSISTENT, jmsMessage.getJMSDeliveryMode());
  assertEquals(0, jmsMessage.getJMSExpiration());
  assertNull(jmsMessage.getJMSMessageID());
  assertEquals(javax.jms.Message.DEFAULT_PRIORITY, jmsMessage.getJMSPriority());
  assertFalse(jmsMessage.getJMSRedelivered());
  assertEquals(0, jmsMessage.getJMSTimestamp());
}

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

sbuf.append(m.getJMSRedelivered());

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

headers.put(JmsHeaders.REDELIVERED, jmsMessage.getJMSRedelivered());

代码示例来源:origin: org.fornax.cartridges/fornax-cartridges-sculptor-framework

protected boolean isJmsRedelivered(Message msg) {
  try {
    return msg.getJMSRedelivered();
  } catch (JMSException e) {
    return false;
  }
}

代码示例来源:origin: org.apache.tomee/openejb-core

@Override
public boolean getJMSRedelivered() throws JMSException {
  return message.getJMSRedelivered();
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-connector

public boolean getJMSRedelivered() throws JMSException
{
 return message.getJMSRedelivered();
}

代码示例来源:origin: org.apache.camel/camel-jms

/**
 * Gets the JMSRedelivered from the message.
 *
 * @param message  the message
 * @return <tt>true</tt> if redelivered, <tt>false</tt> if not, <tt>null</tt> if not able to determine
 */
public static Boolean getJMSRedelivered(Message message) {
  try {
    return message.getJMSRedelivered();
  } catch (Exception e) {
    // ignore if JMS broker do not support this
  }
  return null;
}

代码示例来源:origin: org.apache.qpid/qpid-jca

/**
* Get redelivered status
* @return The value
* @exception JMSException Thrown if an error occurs
*/
public boolean getJMSRedelivered() throws JMSException
{
 if (_log.isTraceEnabled())
 {
   _log.trace("getJMSRedelivered()");
 }
 return _message.getJMSRedelivered();
}

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

/**
* Get redelivered status
*
* @return The value
* @throws JMSException Thrown if an error occurs
*/
@Override
public boolean getJMSRedelivered() throws JMSException {
 if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
   ActiveMQRALogger.LOGGER.trace("getJMSRedelivered()");
 }
 return message.getJMSRedelivered();
}

代码示例来源:origin: org.apache.activemq/artemis-ra

/**
* Get redelivered status
*
* @return The value
* @throws JMSException Thrown if an error occurs
*/
@Override
public boolean getJMSRedelivered() throws JMSException {
 if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
   ActiveMQRALogger.LOGGER.trace("getJMSRedelivered()");
 }
 return message.getJMSRedelivered();
}

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

@Test
public void testRedeliveryWithClientAck() throws Exception {
 conn.connect(defUser, defPass);
 subscribe(conn, "subId", "client");
 sendJmsMessage(getName());
 ClientStompFrame frame = conn.receiveFrame();
 Assert.assertTrue(frame.getCommand().equals(Stomp.Responses.MESSAGE));
 conn.disconnect();
 // message should be received since message was not acknowledged
 MessageConsumer consumer = session.createConsumer(queue);
 Message message = consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertTrue(message.getJMSRedelivered());
}

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

@Test
public void testRedeliveryWithClientAck() throws Exception {
 conn.connect(defUser, defPass);
 subscribe(conn, "subscriptionId", Stomp.Headers.Subscribe.AckModeValues.CLIENT);
 sendJmsMessage(getName());
 ClientStompFrame frame = conn.receiveFrame();
 assertTrue(frame.getCommand().equals(Stomp.Responses.MESSAGE));
 conn.disconnect();
 // message should be received since message was not acknowledged
 MessageConsumer consumer = session.createConsumer(queue);
 Message message = consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertTrue(message.getJMSRedelivered());
}

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

@Test
public void testRedeliveryWithClientAck() throws Exception {
 conn.connect(defUser, defPass);
 subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.CLIENT);
 sendJmsMessage(getName());
 ClientStompFrame frame = conn.receiveFrame(10000);
 Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
 conn.disconnect();
 // message should be received since message was not acknowledged
 MessageConsumer consumer = session.createConsumer(queue);
 Message message = consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertTrue(message.getJMSRedelivered());
}

相关文章