Websphere JMS queue connection issue - ConfigURL property file is not set - websphere

Facing the below exception when try to push msg into jms queue in Wrbsphere server.
Please let me know if any help can get on this.
Exception:
JSAS1480I: **Security is not enabled because the ConfigURL property file is not set.**
javax.naming.NamingException: Error getting WsnNameService properties [Root exception is org.omg.CORBA.TRANSIENT: initial and forwarded IOR inaccessible vmcid: 0x4942f000 minor code: 3591 completed: No]
My code:
private void putmsg() throws NamingException, JMSException, IOException {
Context namingContext = null;
final Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
prop.put(Context.PROVIDER_URL, "iiop://localhost:2809");
prop.put(Context.SECURITY_PRINCIPAL, "admin");
prop.put(Context.SECURITY_CREDENTIALS, "admin");
prop.put("connection.factory", "jms/t24ConnectionFactory");
namingContext = new InitialContext(prop);
ConnectionFactory connectionFactory =
(ConnectionFactory) namingContext.lookup("jms/t24ConnectionFactory");
Destination queue = (Destination) namingContext.lookup("jms/t24OFSQueue");
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession();
String input = FileUtils.readFileToString(new File("C:\\inflow\\ResponseOut1.xml"));
MessageProducer producer = session.createProducer(queue);
TextMessage txtMsg = session.createTextMessage(input);
((MessageProducer) producer).send(txtMsg);
connection.close();
}
I think i have missing some configuration related to websphere.

Related

JMS JMSCC3032 exception

I use IBM MQ. I upgraded the com.ibm.mq jar in my application from 7.5 to 9.1.1.0 as:
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.allclient</artifactId>
<version>9.1.1.0</version>
My consumer that is receiving messages from topic started to get error JMSCC0111.
As I read this is new behavior in the JMS libraries above version 8.0 where by default a JMS ID can not be reused.
As a solution I set clientId on connection as below. I'm getting connection from ConnectionFactory.
public Connection getConnectionWithUuid() throws JMSException {
Connection connection = connFactory.createConnection();
String uid = UUID.randomUUID().toString();
connection.setClientID(uid);
connection.start();
return connection;
}
Now I started to get exception:
JMSCC3032: Resetting the client ID is not allowed.
Connection jmsConnection = null;
Session jmsSession = null;
MessageConsumer consumer = null;
MessageProducer producer = null;
try {
jmsConnection = QueueManager.getInstance().getConnectionWithUuid();
jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination responseTopic = QueueManager.getInstance()
.getDestination(this.parameters.getResponseTopicName());
Destination outGoingQueue = QueueManager.getInstance()
.getDestination(this.parameters.getOutGoingQueueName());
consumer = jmsSession.createConsumer(responseTopic);
producer = jmsSession.createProducer(outGoingQueue);
TextMessage requestMessage = jmsSession.createTextMessage(request);
requestMessage.setJMSCorrelationID(parameters.getSessionId());
producer.send(requestMessage);
logMessage("OutGoing Message:\n", requestMessage);
String response = null;
long begin = System.currentTimeMillis();
while (response == null && System.currentTimeMillis() - begin < protocolTimeoutSecs * 1000) {
Message responseMessage = consumer.receive(protocolTimeoutSecs * 1000);
On the last line (consumer.receive) it throws JMSCC3032.

No mannaged connection when using jms

I am using wildfly jms queue... I'm using wildfly 9.0.2.Final
I make the producer like this :
#Inject
private JMSContext jmsContext;
private JMSProducer jmsProducer;
#Resource(mappedName = "java:/jboss/exported/jms/queue/TosDownloadReport")
private Queue queueDownloadReport;
public void downloadReport(String adminId, DownloadReportFilter filter){
try {
jmsProducer = jmsContext.createProducer();
String requestParam = Json.getInstance().getObjectMapper().writeValueAsString(filter);
LOG.info("requestParam {}", requestParam);
String id = UUID.randomUUID().toString().replace("-", "");
RoutingRequest request = new RoutingRequest();
request.putProperty("id", id);
request.putProperty("adminId", adminId);
request.putProperty("parameterRequest", requestParam);
QueueMsgDownloadReport message = new QueueMsgDownloadReport();
message.setId(id);
message.setAdminId(adminId);
String jsonMsg = Json.getInstance().getObjectMapper().writeValueAsString(message);
gatewayService.send(RESOURCE, METHOD, request);
jmsProducer.send(queueDownloadReport, jsonMsg);
} catch (Exception e) {
LOG.error(e.getMessage(),e);
}
}
But sometimes i get exception like this and i must restart wildfly
2017-05-05 11:08:20,004 ERROR [com.daksa.tos.infrastructure.api.TosTimer] (EJB default - 7) Could not create a session: IJ000453: Unable to get managed connection for java:/JmsXA: javax.jms.JMSRuntimeException: Could not create a session: IJ000453: Unable to get managed connection for java:/JmsXA
Caused by: javax.resource.ResourceException: IJ000655: No managed connections available within configured blocking timeout (30000 [ms])
From what i read, i don't need to call jmsContext.close() if i'm using inject right?
Please tell me what i do wrong...Thx

How to set proxy to ActiveMQConnectionFactory to send messages

I am using spring activemq for sending jms messages to activemq message queue.
The messagequeue is created on a remote server.I have to set a proxy to reach to that message queue server from my local machine.
Can anyone help me on how to add proxy to activemqConnectionFactory class.
I tried using HttpClientTransport, ProxyConnector, NetworkConnector classes where I set the broker URL, but I am not sure how to add those to the activemqconnectionFactory.
Please find the details below:
message.queue.broker.url=ssl://<HOSTNAME>:61617
HttpClientTransport httpClientTransport = new HttpClientTransport(null, new URI(brokerUrl));
httpClientTransport.setProxyHost("<proxyHost>");
httpClientTransport.setProxyPort(3128);
httpClientTransport.start();
ProxyConnector proxy = new ProxyConnector();
proxy.setBind(new URI(brokerUrl));
proxy.setRemote(new URI(brokerUrl));
proxy.start();
NetworkConnector netConnector = new NetworkConnector() {
};
netConnector.setBrokerURL(brokerUrl);
netConnector.start();
ActiveMQConnectionFactory activeMQConnectionfactory = new ActiveMQConnectionFactory(userName, password, brokerUrl);
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(activeMQConnectionfactory);
cachingConnectionFactory.setSessionCacheSize(50);
ActiveMQQueue activeMqQueue = new ActiveMQQueue(destination);
jmsTemplate = new JmsTemplate(sslConnectionFactory);
jmsTemplate.setDefaultDestination(activeMqQueue);
#Override
public void sendMessage(final String text) {
// TODO Auto-generated method stub
this.jmsTemplate.send(new MessageCreator() {
#Override
public Message createMessage(Session session) throws JMSException {
Message message = session.createTextMessage(text);
return message;
}
});
}
When I run the above code, I get ConnectionTimedOutException:
Caused by: javax.jms.JMSException: Could not connect to broker URL: ssl://:61617. Reason: java.net.SocketTimeoutException: connect timed out
I also tried with
ssl://<URL>?transport.proxyHost=<PROXYHOST>amp;transport.proxyPort=3128
Thanks in Advance.

Remove RFH2 header from incoming message in MQ

Currently i am using Websphere MQ V8.
public static void main(String[] args) throws JMSException {
// TODO Auto-generated method stub
try{
MQEnvironment.disableTracing();
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, "localhost");
cf.setStringProperty(WMQConstants.WMQ_PORT, "1414");
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, "TEST_SVR_CONN");
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, "DEVTESTQUEUE");
//cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_DIRECT_HTTP);
//cf.setTransportType(WMQConstants.WMQ_CM_BINDINGS);
//set MQServer =
//HelloWorldConsumer.HelloWorldProducer();
MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection();
MQSession session = (MQSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
MQQueue queue = (MQQueue) session.createQueue("REQUEST");
//queue.setMessageBodyStyle(WMQConstants.WMQ_MESSAGE_BODY_MQ);
queue.setTargetClient(WMQConstants.WMQ_TARGET_DEST_MQ);
queue.setProperty("PROPCTL", "ALL");
((com.ibm.mq.jms.MQQueue)queue).setIntProperty(WMQConstants.WMQ_TARGET_CLIENT, WMQConstants.WMQ_TARGET_DEST_MQ);
connection.start();
MessageConsumer consumer = session.createConsumer(queue);
consumer.setMessageListener(new HelloWorldConsumer());
session.close();
connection.close();
System.out.println("------END------");
}catch(JMSException je){
je.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
}
i have tried by setting TARGCLIENT property to WMQ_TARGET_DEST_MQ and PROPCTL as "NONE/FORCE". Still iam getting the header in the message as
RFH ? ????MQSTR ? 25504.txt ?UPLOAD|1||

Send message to remote JMS queue

I deployed an application on cluster1_machine1 and cluster2_machine2. The queue is in cluster1_machine1.
Using the application in cluster1_machine1 is fine with sending and receiving messages but it is fail in cluster2_machine2 to send a message to queue in cluster1_machine1.
I kept on get the following exception and I know the exception is thrown because of the following code.
WLSession s = (WLSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Exception:
java.lang.AbstractMethodError: retrieveThreadLocalContext
at weblogic.messaging.dispatcher.DispatcherProxy.unmarshalResponse(DispatcherProxy.java:243)
at weblogic.messaging.dispatcher.DispatcherProxy.dispatchSyncTranFuture(DispatcherProxy.java:134)
at weblogic.messaging.dispatcher.DispatcherWrapperState.dispatchSyncTran(DispatcherWrapperState.java:334)
at weblogic.messaging.dispatcher.DispatcherWrapperState.dispatchSyncNoTran(DispatcherWrapperState.java:381)
at weblogic.messaging.dispatcher.DispatcherWrapperState.dispatchSync(DispatcherWrapperState.java:249)
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSync(DispatcherAdapter.java:43)
at weblogic.jms.client.JMSConnection.setupJMSSession(JMSConnection.java:529)
at weblogic.jms.client.JMSConnection.createSessionInternal(JMSConnection.java:497)
at weblogic.jms.client.JMSConnection.createSession(JMSConnection.java:483)
at weblogic.jms.client.WLConnectionImpl.createSession(WLConnectionImpl.java:552)
at jsp_servlet.__enqueue._jspService(__enqueue.java:198)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:416)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:327)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3750)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3714)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2283)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2182)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1491)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Please kindly help. Thank you!
Code in producer:
try {
InitialContext ic = getInitialContext("t3://cluster2_machine2:<PORT>");
ConnectionFactory qconFactory = (ConnectionFactory) ic.lookup("jms/TestConnectionFactory");
Connection connection = qconFactory.createQueueConnection();
WLSession s = (WLSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination queue = (Destination) ic.lookup("jms/TestJMSQueue");
WLMessageProducer producer = (WLMessageProducer) s.createProducer(null);
TextMessage msg = s.createTextMessage();
connection.start();
msg.setText(strMsg);
producer.send(queue,msg);
producer.close();
s.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
private static InitialContext getInitialContext(String url)
throws NamingException {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL, url);
return new InitialContext(env);
}

Resources