【问题标题】:Spring JMS Template - remove RFH Header informationSpring JMS 模板 - 删除 RFH Header 信息
【发布时间】:2016-11-07 20:14:02
【问题描述】:

我目前正在开发一个使用 Spring 的 JMS 消息传递 (JMSTemplate) 的应用程序。应用程序需要将消息发送到无法解密 JMSTemplate 附加到消息的“RFH”标头的大型机队列。有没有办法以编程方式完全删除所有标头信息,以便大型机可以在没有标头的情况下获取消息的原始内容?

这是我的代码...

    MQQueueConnectionFactory connectionFactory = new MQQueueConnectionFactory();
    connectionFactory.setHostName( "127.0.0.1" );
    connectionFactory.setPort( 1414 );
    connectionFactory.setChannel( "S_LOCALHOST" );
    connectionFactory.setQueueManager( "QM_LOCALHOST" );
    connectionFactory.setTransportType( 1 );

    UserCredentialsConnectionFactoryAdapter credentials = new UserCredentialsConnectionFactoryAdapter();
    credentials.setUsername( "" );
    credentials.setPassword( "" );
    credentials.setTargetConnectionFactory( connectionFactory );

    JmsTemplate jmsTemplate = new JmsTemplate( credentials );
    jmsTemplate.setPubSubDomain( false );
    jmsTemplate.setDeliveryMode( javax.jms.DeliveryMode.NON_PERSISTENT );
    jmsTemplate.setExplicitQosEnabled( true );
    jmsTemplate.setReceiveTimeout( 60000 );

    jmsTemplate.convertAndSend( "MY.QUEUE", "cobol data" );

这是消息在 Websphere MQ Explorer 中的样子。如何删除这些值? Spring JMS 甚至有可能吗?如果您需要更多信息,请告诉我...

【问题讨论】:

    标签: spring jms ibm-mq


    【解决方案1】:

    禁止将 RFH 标头发送到非 JMS 队列的一种方法是使用 targetClient 队列 URI 属性,例如

    jmsTemplate.convertAndSend( "queue:///MY.QUEUE?targetClient=1", "cobol data" );
    

    或者,您可以在Queue 对象本身上设置它,然后将其用作jmsTemplate 的目标:

    queue.setTargetClient(WMQConstants.WMQ_CLIENT_NONJMS_MQ);
    

    WebSphere MQ 参考:

    https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.0.0/com.ibm.mq.dev.doc/q032240_.htm

    http://www.ibm.com/support/knowledgecenter/SSFKSJ_9.0.0/com.ibm.mq.javadoc.doc/WMQJMSClasses/com/ibm/mq/jms/MQDestination.html

    【讨论】:

    • 非常感谢ck1,您的第一个sn-p 似乎成功了!关于第二个 sn-p 的问题,我看到其他帖子提到设置 targetClient 但我不知道这是什么类型的 Queue 对象,你能给我你所说的那个队列对象的完全限定包名吗?
    • 谢谢,看起来很有用!!
    猜你喜欢
    • 1970-01-01
    • 2016-12-17
    • 2020-05-04
    • 2016-06-14
    • 2022-01-15
    • 2017-03-09
    • 2012-06-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多