IBM MQ学习过程问题汇总

IBM MQ使用过程问题汇总
----------------------------------------------
1. 客户端发送消息时出现2035问题的解决过程
####环境:win7系统administrator用户,WebSphereMQ8.0
####测试:执行命令"amqsputc.exe Q1"
a---按照教程添加"服务器连接"通道时为MCA指定用户名。无效;
b---执行runmqsc命令,输入alter qmgr chlauth(disabled)禁止权限验证。无效;
c---具体队列管理器/属性/扩展/连接认证(在最后一行),删除。无效;
d---执行runmqsc命令,输入refresh security type(connauth)刷新告诉缓存。生效;
结论:终极解决方案就是依次执行b、c、d步骤。
----------------------------------------------
2. 客户端如何获取消息?
    客户端调用类似MQGET的方法获得消息,可以设置立即返回或者阻塞等待,如果是阻塞等待又可以设置超时。
3. 如何发送文件?
    发送端需要先将文件内容转成字节流,然后将字节流打入消息对象中,然后发送;
    接收端接收到消息对象后,将文件内容字节流写入目的文件中;
4. 如何设置消息持久化、非持久化?
    queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

5. 远程管理队列管理器
    通道/新建/服务器连接通道/SYSTEM.ADMIN.SVRCONN;
    一般Unix、Linux平台中MQ默认的字符集为819,而Windows平台为1381;

----------------------------------------------
6. WMQ与AMQ之间如何建立桥接?
    使用AMQ内置的camel实现:
    下载apache-activemq-5.13.1-bin.zip并解压;
    安装WMQ8.0;
    将WMQ下Java/lib目录下的jar包拷贝到AMQ的lib目录下;
    修改camel.xml配置文件拷贝到conf目录下;
    启动activemq,测试桥接;

<beans
   xmlns="http://www.springframework.org/schema/beans"  
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
     http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  
    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">

        <!-- You can use Spring XML syntax to define the routes here using the <route> element -->
        <route>
            <description>Example Camel Route</description>
            <from uri="activemq:example.A"/>
            <to uri="wasmq:Q2"/>
        </route>
    </camelContext>

    <!--
       Lets configure some Camel endpoints
    
       http://camel.apache.org/components.html
    -->

    <!-- configure the camel activemq component to use the current broker -->
    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
        <property name="connectionFactory">
          <bean class="org.apache.activemq.ActiveMQConnectionFactory">
            <property name="brokerURL" value="vm://localhost?create=true"/>
            <property name="userName" value="${activemq.username}"/>
            <property name="password" value="${activemq.password}"/>
          </bean>
        </property>
    </bean>
    <bean id="activemq1" class="org.apache.activemq.camel.component.ActiveMQComponent" >
        <property name="connectionFactory">
          <bean class="org.apache.activemq.ActiveMQConnectionFactory">
            <property name="brokerURL" value="tcp://localhost:61616"/>
            <property name="userName" value="${activemq.username}"/>
            <property name="password" value="${activemq.password}"/>
          </bean>
        </property>
    </bean>
    <bean id="wasmq" class="org.apache.camel.component.jms.JmsComponent">
        <property name="connectionFactory">
            <bean  class="com.ibm.mq.jms.MQQueueConnectionFactory">
                <property name="transportType" value="1" />
                <property name="hostName" value="192.168.51.183" />
                <property name="port" value="1414" />
                <property name="queueManager" value="QM_ORANGE" />
                <property name="channel" value="CLIENT.QM_ORANGE" />
                <property name="useConnectionPooling" value="true" />
            </bean>   
        </property>
    </bean>

</beans>
View Code

 

posted @ 2016-02-23 10:14  feilv  阅读(2424)  评论(0编辑  收藏  举报