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

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

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

Message.setJMSExpiration介绍

[英]Sets the message's expiration value.

This method is for use by JMS providers only to set this field when a message is sent. This message cannot be used by clients to configure the expiration time of the message. This method is public to allow a JMS provider to set this field when sending a message whose implementation is not its own.
[中]设置消息的过期值。
此方法仅供JMS提供程序在发送消息时用于设置此字段。客户端无法使用此消息配置消息的过期时间。此方法是公共的,允许JMS提供程序在发送非其自身实现的消息时设置此字段。

代码示例

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

message.setJMSDeliveryMode(Integer.parseInt(entry.getValue()));
} else if (entry.getKey().equals(JmsHeaders.EXPIRATION)) {
  message.setJMSExpiration(Integer.parseInt(entry.getValue()));
} else if (entry.getKey().equals(JmsHeaders.PRIORITY)) {
  message.setJMSPriority(Integer.parseInt(entry.getValue()));

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

@Test
public void jmsExpirationMappedToHeader() throws JMSException {
  long expiration = 1000L;
  javax.jms.Message jmsMessage = new StubTextMessage();
  jmsMessage.setJMSExpiration(expiration);
  assertInboundHeader(jmsMessage, JmsHeaders.EXPIRATION, expiration);
}

代码示例来源: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: wildfly/wildfly

jmsMessage.setJMSExpiration(0);
} else {
  jmsMessage.setJMSExpiration(System.currentTimeMillis() + timeToLive);

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

message.setJMSExpiration(expiration);
message.setJMSPriority(priority);
message.setJMSRedelivered(false);

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

@Override
public void setJMSExpiration(final long expiration) throws JMSException {
  message.setJMSExpiration(expiration);
}

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

public void setJMSExpiration(long expiration) throws JMSException
{
 message.setJMSExpiration(expiration);
}

代码示例来源:origin: org.jboss.genericjms/generic-jms-ra-jar

public void setJMSExpiration(long expiration) throws JMSException {
  message.setJMSExpiration(expiration);
}

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

/**
* Set expiration
* @param expiration The value
* @exception JMSException Thrown if an error occurs
*/
public void setJMSExpiration(final long expiration) throws JMSException
{
 if (_log.isTraceEnabled())
 {
   _log.trace("setJMSExpiration(" + expiration + ")");
 }
 _message.setJMSExpiration(expiration);
}

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

/**
* Set expiration
*
* @param expiration The value
* @throws JMSException Thrown if an error occurs
*/
@Override
public void setJMSExpiration(final long expiration) throws JMSException {
 if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
   ActiveMQRALogger.LOGGER.trace("setJMSExpiration(" + expiration + ")");
 }
 message.setJMSExpiration(expiration);
}

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

/**
* Set expiration
*
* @param expiration The value
* @throws JMSException Thrown if an error occurs
*/
@Override
public void setJMSExpiration(final long expiration) throws JMSException {
 if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
   ActiveMQRALogger.LOGGER.trace("setJMSExpiration(" + expiration + ")");
 }
 message.setJMSExpiration(expiration);
}

代码示例来源:origin: org.logicblaze.lingo/lingo

protected void populateHeaders(Message requestMessage) throws JMSException {
  if (correlationID != null) {
    requestMessage.setJMSCorrelationID(correlationID);
  }
  if (jmsType != null) {
    requestMessage.setJMSType(jmsType);
  }
  if (jmsExpiration >= 0) {
    requestMessage.setJMSExpiration(jmsExpiration);
  }
  int jmsPriority = getJmsPriority();
  if (jmsPriority >= 0) {
    requestMessage.setJMSPriority(jmsPriority);
  }
  if (messageProperties != null) {
    for (Iterator iter = messageProperties.entrySet().iterator(); iter.hasNext();) {
      Map.Entry entry = (Map.Entry) iter.next();
      String name = entry.getKey().toString();
      Object value = entry.getValue();
      requestMessage.setObjectProperty(name, value);
    }
  }
}

代码示例来源:origin: sk.seges.sesam/sesam-remote

private Response sendResponse(Message message, Serializable returnValue, Throwable invocationException)
    throws JMSException {        
  Destination reply = message.getJMSReplyTo();
  if(log.isDebugEnabled())
    log.debug("Replying to temp. topic = " + reply + " with returnValue = " + returnValue, invocationException);
  if(reply == null)
    return null;
  MessageProducer producer = producerSession.createProducer(reply);
  producer.setDeliveryMode(configuration.getDeliveryMode());
  Response response = new Response(returnValue, invocationException);
  Message m = responseMessageBuilder.createMessage(message, response);
  m.setJMSExpiration(configuration.getInvocationTimeout());
  if(configuration.getDestinationSelector() != null && !configuration.getDestinationSelector().isEmpty()) {
    m.setStringProperty(Constants.DESTINATION_SELECTOR, configuration.getDestinationSelector());
  }
  
  producer.send(m);
  producer.close();
  
  if(log.isDebugEnabled()) {
    log.debug("Created response = " + response);
  }
  return response;
}

代码示例来源:origin: timewalker74/ffmq

protected final void setupMessage( Destination destinationRef , Message message , int deliveryMode , int priority , long timeToLive) throws JMSException
{
  long now = System.currentTimeMillis();
  
  // Setup headers
  message.setJMSMessageID(uuidProvider.getUUID());
  message.setJMSTimestamp(disableMessageTimestamp ? 0 : now);
  message.setJMSDeliveryMode(deliveryMode);
  message.setJMSPriority(priority);
  message.setJMSExpiration(timeToLive > 0 ? timeToLive+now : 0);
  message.setJMSDestination(destinationRef);
}

代码示例来源:origin: org.ballerinalang/ballerina-jms

@Override
  public void execute(Context context, CallableUnitCallback callableUnitCallback) {

    Struct messageStruct = BallerinaAdapter.getReceiverObject(context);
    Message message = BallerinaAdapter.getNativeObject(messageStruct,
                              Constants.JMS_MESSAGE_OBJECT,
                              Message.class,
                              context);
    long value = context.getIntArgument(0);

    try {
      message.setJMSExpiration(value);
    } catch (JMSException e) {
      BallerinaAdapter.returnError("Error when setting expiration", context, e);
    }
  }
}

代码示例来源:origin: com.github.fridujo/spring-automocker

public Message toMessage(Session session) throws JMSException {
  Message message = toMessageInternal(session);
  if (messageId != null)
    message.setJMSMessageID(messageId);
  if (timestamp != null)
    message.setJMSTimestamp(timestamp);
  if (correlationId != null)
    message.setJMSCorrelationID(correlationId);
  if (replyTo != null)
    message.setJMSReplyTo(session.createQueue(replyTo));
  if (deliveryMode != null)
    message.setJMSDeliveryMode(deliveryMode);
  if (redelivered != null)
    message.setJMSRedelivered(redelivered);
  if (type != null)
    message.setJMSType(type);
  if (expiration != null)
    message.setJMSExpiration(expiration);
  if (priority != null)
    message.setJMSPriority(priority);
  properties.entrySet()
    .forEach(ThrowingConsumer.silent(e -> message.setObjectProperty(e.getKey(), e.getValue())));
  return message;
}

代码示例来源:origin: sk.seges.sesam/sesam-remote

private void send(InvocationContext context, RemoteCommand command, Integer priority, Destination reply) throws JMSException {
    MessageProducer producer = context.getProducer();
    producer.setDeliveryMode(configuration.getDeliveryMode());

    producer.setTimeToLive(configuration.getInvocationTimeout());

    if (priority != null) {
      // 0-4,5-9/def 4(spec)
      producer.setPriority(priority.intValue());
    }
    
    Message m = context.getProducerSession().createObjectMessage(command);
    m.setJMSExpiration(configuration.getInvocationTimeout());
    if(configuration.getDestinationSelector() != null && !configuration.getDestinationSelector().isEmpty()) {
      m.setStringProperty(Constants.DESTINATION_SELECTOR, configuration.getDestinationSelector());
    }
    
    addPropertiesToMessage(m);
    
    if (reply != null) {
      m.setJMSReplyTo(reply);
    }
    producer.send(m);
  }
}

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

/**
   * 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: org.fusesource.stompjms/stompjms-client

/**
   * 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(StompJmsConnection connection, Message fromMessage, Message toMessage) throws JMSException {
    toMessage.setJMSMessageID(fromMessage.getJMSMessageID());
    toMessage.setJMSCorrelationID(fromMessage.getJMSCorrelationID());
    toMessage.setJMSReplyTo(transformDestination(connection, fromMessage.getJMSReplyTo()));
    toMessage.setJMSDestination(transformDestination(connection, 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: org.apache.activemq/activemq-all

/**
   * 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);
    }
  }
}

相关文章