Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-3259

map jmspriority between jmsmessage and spring message

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 2.0.5
    • Fix Version/s: 4.0 M3
    • Component/s: JMS Support
    • Labels:
    • Environment:
      spring 3, spring integration 2.0.5

      Description

      look at reference URL, as Gary requested here is the feature request.

      at the moment you need an extra class to map the JMSPriority, and you have to reference it in the <jms:message-driven-channel-adapter> or <jms:outbound-adapter> with the header-mapper attribute.

      example:

      <bean id="common.integration.jms.PriorityHeaderMapper" class="xxx.yyy.common.integration.jms.PriorityHeaderMapper" />   
      
      <jms:message-driven-channel-adapter id="inbound.queue1.jms.adapter"  container="inbound_jms_container"
         channel="transform_msg_log_channel"  acknowledge="auto" auto-startup="false"
         message-converter="queue1.spring.simplemessage.converter"
         header-mapper="common.integration.jms.PriorityHeaderMapper" />
      

      my PriorityHeaderMapper is the following:

      public class PriorityHeaderMapper extends DefaultJmsHeaderMapper {
      	private static final Logger logger = Logger.getLogger(PriorityHeaderMapper.class);
      	
      	@Override
      	public Map<String, Object> toHeaders(javax.jms.Message jmsMessage) {
      		Map<String, Object> headers = super.toHeaders(jmsMessage);
      		try {
      			headers.put("JMSPriority", String.valueOf(jmsMessage.getJMSPriority()) );
      		}
      		catch (javax.jms.JMSException e) {
      			logger.warn("jmsMessage.getJMSPriority() did not work.", e);
      		}
      		return headers;		
      	}
      	
      	@Override
      	public void fromHeaders(MessageHeaders headers, javax.jms.Message jmsMessage) {
      		super.fromHeaders(headers, jmsMessage);
      		int priority = Integer.parseInt(headers.get("JMSPriority")); // missing catch for numeric exception
      		try {
      			jmsMessage.setJMSPriority(priority); 
      		} catch (javax.jms.JMSException e) {
      			logger.warn("jmsMessage.setJMSPriority() did not work.", e);
      		}
      	}
      }
      

        Attachments

          Activity

            People

            Assignee:
            grussell Gary Russell
            Reporter:
            donneker Stefan Hummert
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 2d
                2d
                Remaining:
                Remaining Estimate - 2d
                2d
                Logged:
                Time Spent - Not Specified
                Not Specified