1
votes

I want to connect to a WSMQ queue (running on a server outside of my company network) from a JBoss AS server (5.1) using the resource-adapter supplied by Websphere MQ (7).

I set up a connection factory and want to configure it to use our proxy-server, which is needed to connect to a machine outside the network. Our proxy-server requires authentication.

I found the (MQConnectionFactory) properties proxyHostName and proxyPort but no means to add authentication (username / password).

The Java properties http.proxyHost etc. don't make any difference, which makes sense since JMS doesn't use http.

Configuring the socksProxyHost, socksProxyPort, java.net.socks.username and java.net.socks.password properties also has no effect.

I'm at a loss here, how can I connect from JBoss AS to a remote WSMQ queue using a proxy server which requires authentication?

2

2 Answers

7
votes

You need to wrap the MQConnectionFactory with org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter

    MQConnectionFactory connectionFactory = new MQConnectionFactory();
    connectionFactory.setTransportType(1);
    connectionFactory.setHostName("localhost");
    connectionFactory.setPort(1415);
    connectionFactory.setQueueManager("DEV.QMGR");

    UserCredentialsConnectionFactoryAdapter connectionFactoryAdapter=new UserCredentialsConnectionFactoryAdapter();
    connectionFactoryAdapter.setTargetConnectionFactory(connectionFactory);
    connectionFactoryAdapter.setUsername("myusername");
    connectionFactoryAdapter.setPassword("mypassword");

    JmsComponent jmsComponent = new JmsComponent();
    jmsComponent.setConnectionFactory(connectionFactoryAdapter);
1
votes

When you instantiate an MQQueueConnectionFactory, you have two methods to create a QueueConnection instance, one does let you specify the userId and password.

String userId = "test";
String password = "password";
mqQueueConnectionFactory = new com.ibm.mq.jms.MQQueueConnectionFactory();
QueueConnection queueConnection =
mqQueueConnectionFactory.createQueueConnection(userId,password);