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

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

本文整理了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

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

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

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

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

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

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

  1. message.setJMSExpiration(expiration);
  2. message.setJMSPriority(priority);
  3. message.setJMSRedelivered(false);

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

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

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

  1. public void setJMSExpiration(long expiration) throws JMSException
  2. {
  3. message.setJMSExpiration(expiration);
  4. }

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

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

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

  1. /**
  2. * Set expiration
  3. * @param expiration The value
  4. * @exception JMSException Thrown if an error occurs
  5. */
  6. public void setJMSExpiration(final long expiration) throws JMSException
  7. {
  8. if (_log.isTraceEnabled())
  9. {
  10. _log.trace("setJMSExpiration(" + expiration + ")");
  11. }
  12. _message.setJMSExpiration(expiration);
  13. }

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

  1. /**
  2. * Set expiration
  3. *
  4. * @param expiration The value
  5. * @throws JMSException Thrown if an error occurs
  6. */
  7. @Override
  8. public void setJMSExpiration(final long expiration) throws JMSException {
  9. if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
  10. ActiveMQRALogger.LOGGER.trace("setJMSExpiration(" + expiration + ")");
  11. }
  12. message.setJMSExpiration(expiration);
  13. }

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

  1. /**
  2. * Set expiration
  3. *
  4. * @param expiration The value
  5. * @throws JMSException Thrown if an error occurs
  6. */
  7. @Override
  8. public void setJMSExpiration(final long expiration) throws JMSException {
  9. if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
  10. ActiveMQRALogger.LOGGER.trace("setJMSExpiration(" + expiration + ")");
  11. }
  12. message.setJMSExpiration(expiration);
  13. }

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

  1. protected void populateHeaders(Message requestMessage) throws JMSException {
  2. if (correlationID != null) {
  3. requestMessage.setJMSCorrelationID(correlationID);
  4. }
  5. if (jmsType != null) {
  6. requestMessage.setJMSType(jmsType);
  7. }
  8. if (jmsExpiration >= 0) {
  9. requestMessage.setJMSExpiration(jmsExpiration);
  10. }
  11. int jmsPriority = getJmsPriority();
  12. if (jmsPriority >= 0) {
  13. requestMessage.setJMSPriority(jmsPriority);
  14. }
  15. if (messageProperties != null) {
  16. for (Iterator iter = messageProperties.entrySet().iterator(); iter.hasNext();) {
  17. Map.Entry entry = (Map.Entry) iter.next();
  18. String name = entry.getKey().toString();
  19. Object value = entry.getValue();
  20. requestMessage.setObjectProperty(name, value);
  21. }
  22. }
  23. }

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

  1. private Response sendResponse(Message message, Serializable returnValue, Throwable invocationException)
  2. throws JMSException {
  3. Destination reply = message.getJMSReplyTo();
  4. if(log.isDebugEnabled())
  5. log.debug("Replying to temp. topic = " + reply + " with returnValue = " + returnValue, invocationException);
  6. if(reply == null)
  7. return null;
  8. MessageProducer producer = producerSession.createProducer(reply);
  9. producer.setDeliveryMode(configuration.getDeliveryMode());
  10. Response response = new Response(returnValue, invocationException);
  11. Message m = responseMessageBuilder.createMessage(message, response);
  12. m.setJMSExpiration(configuration.getInvocationTimeout());
  13. if(configuration.getDestinationSelector() != null && !configuration.getDestinationSelector().isEmpty()) {
  14. m.setStringProperty(Constants.DESTINATION_SELECTOR, configuration.getDestinationSelector());
  15. }
  16. producer.send(m);
  17. producer.close();
  18. if(log.isDebugEnabled()) {
  19. log.debug("Created response = " + response);
  20. }
  21. return response;
  22. }

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

  1. protected final void setupMessage( Destination destinationRef , Message message , int deliveryMode , int priority , long timeToLive) throws JMSException
  2. {
  3. long now = System.currentTimeMillis();
  4. // Setup headers
  5. message.setJMSMessageID(uuidProvider.getUUID());
  6. message.setJMSTimestamp(disableMessageTimestamp ? 0 : now);
  7. message.setJMSDeliveryMode(deliveryMode);
  8. message.setJMSPriority(priority);
  9. message.setJMSExpiration(timeToLive > 0 ? timeToLive+now : 0);
  10. message.setJMSDestination(destinationRef);
  11. }

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

  1. @Override
  2. public void execute(Context context, CallableUnitCallback callableUnitCallback) {
  3. Struct messageStruct = BallerinaAdapter.getReceiverObject(context);
  4. Message message = BallerinaAdapter.getNativeObject(messageStruct,
  5. Constants.JMS_MESSAGE_OBJECT,
  6. Message.class,
  7. context);
  8. long value = context.getIntArgument(0);
  9. try {
  10. message.setJMSExpiration(value);
  11. } catch (JMSException e) {
  12. BallerinaAdapter.returnError("Error when setting expiration", context, e);
  13. }
  14. }
  15. }

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

  1. public Message toMessage(Session session) throws JMSException {
  2. Message message = toMessageInternal(session);
  3. if (messageId != null)
  4. message.setJMSMessageID(messageId);
  5. if (timestamp != null)
  6. message.setJMSTimestamp(timestamp);
  7. if (correlationId != null)
  8. message.setJMSCorrelationID(correlationId);
  9. if (replyTo != null)
  10. message.setJMSReplyTo(session.createQueue(replyTo));
  11. if (deliveryMode != null)
  12. message.setJMSDeliveryMode(deliveryMode);
  13. if (redelivered != null)
  14. message.setJMSRedelivered(redelivered);
  15. if (type != null)
  16. message.setJMSType(type);
  17. if (expiration != null)
  18. message.setJMSExpiration(expiration);
  19. if (priority != null)
  20. message.setJMSPriority(priority);
  21. properties.entrySet()
  22. .forEach(ThrowingConsumer.silent(e -> message.setObjectProperty(e.getKey(), e.getValue())));
  23. return message;
  24. }

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

  1. private void send(InvocationContext context, RemoteCommand command, Integer priority, Destination reply) throws JMSException {
  2. MessageProducer producer = context.getProducer();
  3. producer.setDeliveryMode(configuration.getDeliveryMode());
  4. producer.setTimeToLive(configuration.getInvocationTimeout());
  5. if (priority != null) {
  6. // 0-4,5-9/def 4(spec)
  7. producer.setPriority(priority.intValue());
  8. }
  9. Message m = context.getProducerSession().createObjectMessage(command);
  10. m.setJMSExpiration(configuration.getInvocationTimeout());
  11. if(configuration.getDestinationSelector() != null && !configuration.getDestinationSelector().isEmpty()) {
  12. m.setStringProperty(Constants.DESTINATION_SELECTOR, configuration.getDestinationSelector());
  13. }
  14. addPropertiesToMessage(m);
  15. if (reply != null) {
  16. m.setJMSReplyTo(reply);
  17. }
  18. producer.send(m);
  19. }
  20. }

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

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

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

  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. }

相关文章