IBM MQ Create Context throws com.ibm.mq.jmqi.JmqiException "Channel not defined remotely" (RC 2540) - jms

While trying to create the context, this code throws the exception below:
package com.mycompany.mq.client;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Logger;
import javax.jms.JMSConsumer;
import javax.jms.JMSContext;
import javax.jms.JMSProducer;
import javax.jms.Queue;
import javax.jms.TextMessage;
import org.junit.Assert;
import org.junit.Test;
import com.ibm.msg.client.jms.JmsConnectionFactory;
import com.ibm.msg.client.jms.JmsFactoryFactory;
import com.ibm.msg.client.wmq.WMQConstants;
import com.prowidesoftware.swift.io.RJEReader;
import com.prowidesoftware.swift.model.SwiftMessage;
public class FileScanner {
private static final Logger logger = Logger.getLogger("RJEFileParser");
#Test
public void testPublish() throws Exception {
int count=0;
long m1,m2;
// Create a connection factory
JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
JmsConnectionFactory cf = ff.createConnectionFactory();
// Set the properties
String s;
s=Config.get("HOST"); // 10.32.1.69
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, s);
s=Config.get("PORT"); // 1414
cf.setIntProperty(WMQConstants.WMQ_PORT, Integer.parseInt(s));
s=Config.get("CHANNEL"); // MQCLI.CLNTCONN
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, s);
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
s=Config.get("QMGR"); // RJE_PerfTest
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, s);
cf.setStringProperty(WMQConstants.WMQ_APPLICATIONNAME, "mq-cli");
cf.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, true);
s=Config.get("APP_USER"); // app
cf.setStringProperty(WMQConstants.USERID, s);
s=Config.get("APP_PASSWORD"); // password
cf.setStringProperty(WMQConstants.PASSWORD, s);
// Create JMS objects
try {
JMSContext context = cf.createContext(); // Throws exception
...
} catch (FileNotFoundException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
} catch (IOException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
}
The exception thrown:
com.ibm.msg.client.jms.DetailedJMSRuntimeException: JMSWMQ0018: Failed
to connect to queue manager 'RJE_PerfTest' with connection mode
'Client' and host name '10.32.1.69(1414)'. Check the queue manager is
started and if running in client mode, check there is a listener
running. Please see the linked exception for more information. at
com.ibm.msg.client.jms.DetailedJMSException.getUnchecked(DetailedJMSException.java:267)
at
com.ibm.msg.client.jms.internal.JmsErrorUtils.convertJMSException(JmsErrorUtils.java:173)
at
com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createContext(JmsConnectionFactoryImpl.java:478)
at
com.mycompany.mq.client.FileScanner.testPublish(FileScanner.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at
org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at
org.junit.runners.ParentRunner.run(ParentRunner.java:363) at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: com.ibm.mq.MQException: JMSCMQ0001: IBM MQ call failed with
compcode '2' ('MQCC_FAILED') reason '2540'
('MQRC_UNKNOWN_CHANNEL_NAME'). at
com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:203)
at
com.ibm.msg.client.wmq.internal.WMQConnection.(WMQConnection.java:424)
at
com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:8475)
at
com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:7815)
at
com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl._createConnection(JmsConnectionFactoryImpl.java:303)
at
com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createContext(JmsConnectionFactoryImpl.java:444)
... 24 more Caused by: com.ibm.mq.jmqi.JmqiException:
CC=2;RC=2540;AMQ9204: Connection to host '10.32.1.69(1414)' rejected.
[1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2540;AMQ9520: Channel not
defined remotely.
[3=MQCLI.CLNTCONN]],3=10.32.1.69(1414),5=RemoteConnection.analyseErrorSegment]
at
com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:2314)
at
com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1285)
at
com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.jmqiConnect(InterceptedJmqiImpl.java:377)
at com.ibm.mq.ese.jmqi.ESEJMQI.jmqiConnect(ESEJMQI.java:562) at
com.ibm.msg.client.wmq.internal.WMQConnection.(WMQConnection.java:357)
... 28 more Caused by: com.ibm.mq.jmqi.JmqiException:
CC=2;RC=2540;AMQ9520: Channel not defined remotely. [3=MQCLI.CLNTCONN]
at
com.ibm.mq.jmqi.remote.impl.RemoteConnection.analyseErrorSegment(RemoteConnection.java:4464)
at
com.ibm.mq.jmqi.remote.impl.RemoteConnection.receiveTSH(RemoteConnection.java:3199)
at
com.ibm.mq.jmqi.remote.impl.RemoteConnection.initSess(RemoteConnection.java:1274)
at
com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:895)
at
com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSessionFromNewConnection(RemoteConnectionSpecification.java:416)
at
com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSession(RemoteConnectionSpecification.java:312)
at
com.ibm.mq.jmqi.remote.impl.RemoteConnectionPool.getSession(RemoteConnectionPool.java:146)
at
com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1761)
... 32 more
DIS CHANNEL ('MQCLI.CLNTCONN')
3 : DIS CHANNEL ('MQCLI.CLNTCONN')
AMQ8414: Display Channel details.
CHANNEL(MQCLI.CLNTCONN) CHLTYPE(CLNTCONN)
AFFINITY(PREFERRED) ALTDATE(2020-03-06)
ALTTIME(11.34.36) CERTLABL( )
CLNTWGHT(0) COMPHDR(NONE)
COMPMSG(NONE) CONNAME(10.32.1.69)
DEFRECON(NO) DESCR( )
HBINT(300) KAINT(AUTO)
LOCLADDR( ) MAXMSGL(4194304)
MODENAME( ) PASSWORD( )
QMNAME(RJE_PerfTest) RCVDATA( )
RCVEXIT( ) SCYDATA( )
SCYEXIT( ) SENDDATA( )
SENDEXIT( ) SHARECNV(10)
SSLCIPH( ) SSLPEER( )
TPNAME( ) TRPTYPE(TCP)
USERID( )
With the Queue Manager configured as
DIS QMGR
2 : DIS QMGR
AMQ8408: Display Queue Manager details.
QMNAME(RJE_PerfTest) ACCTCONO(DISABLED)
ACCTINT(1800) ACCTMQI(OFF)
ACCTQ(OFF) ACTIVREC(MSG)
ACTVCONO(DISABLED) ACTVTRC(OFF)
ALTDATE(2020-03-04) ALTTIME(15.48.24)
AUTHOREV(DISABLED) CCSID(437)
CERTLABL(ibmwebspheremqrje_perftest) CERTVPOL(ANY)
CHAD(DISABLED) CHADEV(DISABLED)
CHADEXIT( ) CHLEV(DISABLED)
CHLAUTH(ENABLED) CLWLDATA( )
CLWLEXIT( ) CLWLLEN(100)
CLWLMRUC(999999999) CLWLUSEQ(LOCAL)
CMDEV(DISABLED) CMDLEVEL(800)
COMMANDQ(SYSTEM.ADMIN.COMMAND.QUEUE) CONFIGEV(DISABLED)
CONNAUTH(SYSTEM.DEFAULT.AUTHINFO.IDPWOS)
CRDATE(2020-02-20) CRTIME(16.25.00)
CUSTOM( ) DEADQ( )
DEFCLXQ(SCTQ) DEFXMITQ( )
DESCR( ) DISTL(YES)
INHIBTEV(DISABLED) IPADDRV(IPV4)
LOCALEV(DISABLED) LOGGEREV(DISABLED)
MARKINT(5000) MAXHANDS(256)
MAXMSGL(104857600) MAXPROPL(NOLIMIT)
MAXPRTY(9) MAXUMSGS(10000)
MONACLS(QMGR) MONCHL(OFF)
MONQ(OFF) PARENT( )
PERFMEV(DISABLED) PLATFORM(WINDOWSNT)
PSMODE(ENABLED) PSCLUS(ENABLED)
PSNPMSG(DISCARD) PSNPRES(NORMAL)
PSRTYCNT(5) PSSYNCPT(IFPER)
QMID(RJE_PerfTest_2020-02-20_16.25.00)
REMOTEEV(DISABLED) REPOS( )
REPOSNL( ) REVDNS(ENABLED)
ROUTEREC(MSG) SCHINIT(QMGR)
SCMDSERV(QMGR) SPLCAP(DISABLED)
SSLCRLNL( ) SSLCRYP( )
SSLEV(DISABLED) SSLFIPS(NO)
SSLKEYR(C:\ProgramData\IBM\MQ\qmgrs\RJE_PerfTest\ssl\key)
SSLRKEYC(0) STATACLS(QMGR)
STATCHL(OFF) STATINT(1800)
STATMQI(OFF) STATQ(OFF)
STRSTPEV(ENABLED) SUITEB(NONE)
SYNCPT TREELIFE(1800)
TRIGINT(999999999) VERSION(08000005)
XRCAP(NO)
The connectivity works fine.
How to troubleshoot this problem?
Thanks in advance.

This error comes out of a basic confusion between the channel types.
The client connection channel configured in the server is for something else, as pointed out in this forum: https://www.tek-tips.com/viewthread.cfm?qid=248122
"When you say you created a 'Client Connection' on the Queue Manager,
do you mean you created a channel with type CLNTCONN? This needs to be
type SVRCONN to allow client connections. CLNTCONN channels are never
use dby QMgrs - they are only there to create Channel Tables for
clients."
The client connection requires a server connection channel, created as explained here>
https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q031730_.htm
DEFINE CHANNEL(SWFMQ.CHANNEL) CHLTYPE(SVRCONN) TRPTYPE(TCP)
7 : DEFINE CHANNEL(SWFMQ.CHANNEL) CHLTYPE(SVRCONN) TRPTYPE(TCP)
AMQ8014: WebSphere MQ channel created.
Now my channel looks:
DIS CHANNEL ('SWFMQ.CHANNEL')
8 : DIS CHANNEL ('SWFMQ.CHANNEL')
AMQ8414: Display Channel details.
CHANNEL(SWFMQ.CHANNEL) CHLTYPE(SVRCONN)
ALTDATE(2020-03-06) ALTTIME(13.09.41)
CERTLABL( ) COMPHDR(NONE)
COMPMSG(NONE) DESCR( )
DISCINT(0) HBINT(300)
KAINT(AUTO) MAXINST(999999999)
MAXINSTC(999999999) MAXMSGL(4194304)
MCAUSER( ) MONCHL(QMGR)
RCVDATA( ) RCVEXIT( )
SCYDATA( ) SCYEXIT( )
SENDDATA( ) SENDEXIT( )
SHARECNV(10) SSLCAUTH(REQUIRED)
SSLCIPH( ) SSLPEER( )
TRPTYPE(TCP)

Related

When using the SWT_AWT bridge I cannot quit app using `Command` + `q`

I'm trying to make a application that rely on SWT (not the Eclipse Workbench) use Swing component, however I noticed that just adding an SWT_AWT frame prevent the use of the shortcut command+q, and I'm not sure why or how to work around this.
I'm developing on an Intel macOs (but depending on your platform so adapt you dependencies)
org.eclipse.platform:org.eclipse.swt.cocoa.macosx.x86_64:3.120.0
Here's the reproducer:
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
public class SWTKeyLogger implements Listener{
public static void main(String[] args) {
Display.setAppName("SWT AWT Bridge reproducer");
var display = new Display();
var shell = new Shell(display, SWT.CLOSE | SWT.MIN | SWT.RESIZE | SWT.TITLE | SWT.BORDER);
shell.setSize(400, 200);
shell.setText("Press Key on the blank window");
Listener listener = e -> System.out.println("[SWT] " + e.type == SWT.KeyDown ? "Key Down" : "Key Up");
var swingComposite = new Composite(shell, SWT.EMBEDDED);
swingComposite.setLayout(new GridLayout(1, true));
swingComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
swingComposite.addListener(SWT.KeyDown, listener);
swingComposite.addListener(SWT.KeyUp, listener);
var frame = SWT_AWT.new_Frame(swingComposite);
frame.addKeyListener(new KeyAdapter() {
#Override
public void keyReleased(KeyEvent e) {
System.out.println("[AWT] Key released");
}
});
}
}
When runing the above code typing command+q doesn't exit the application, instead it hangs, and it may have to be forcefully terminated.
The listener installed on the AWT frame however report the keys, but not the SWT liteners.
And removing the frame make things work again, i.e. typing command+q terminate the application. And the SWT listeners on the composite report the keys.
- var frame = SWT_AWT.new_Frame(swingComposite);
- frame.addKeyListener(new KeyAdapter() {
- #Override
- public void keyReleased(KeyEvent e) {
- System.out.println("[AWT] Key released");
- }
- });
Thanks for any guidance.

Connection closed while handshake in process with websockets

I have a problem when sending a message to a websocket server.
2020-06-15 17:06:51,830 INFO [snc.mob.gro.myt.con.ws.MutinyWebsocket] (vert.x-eventloop-thread-6) erreur {}: io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Connection closed while handsh
ake in process
at io.vertx.core.http.impl.WebSocketHandshakeInboundHandler.channelInactive(WebSocketHandshakeInboundHandler.java:57)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:260)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:246)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:239)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelInactive(CombinedChannelDuplexHandler.java:418)
at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:386)
at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:351)
at io.netty.handler.codec.http.HttpClientCodec$Decoder.channelInactive(HttpClientCodec.java:288)
at io.netty.channel.CombinedChannelDuplexHandler.channelInactive(CombinedChannelDuplexHandler.java:221)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:260)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:246)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:239)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:260)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:246)
at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:901)
at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:818)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:497)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
I tried with some chrome plugins and everything works fine.
Here is my code :
public void send(final String message){
WebSocketConnectOptions wsoptions = new WebSocketConnectOptions()
.setSsl(Boolean.FALSE).setURI( "/" ).setPort( 9304 ).setHost( "myserver.com" );
HttpClientOptions httpClientOptions = new HttpClientOptions( )
.setTrustAll( true ).setSsl( false );
Uni< WebSocket > webSocketUni = vertx.createHttpClient(httpClientOptions).webSocket( wsoptions );
webSocketUni
.subscribe()
.with( a -> {
a.handler( data -> {
log.info( "server message {}", data.toString() );
a.writeTextMessageAndForget( message );
} );
},
e -> log.info( "erreur {}", e ))
;
}
I don't know what's the handshake problem with my client.
Any help really appreciated.
Thank you!

c3p0 error in spark streaming

i use c3po to connect jdbc(impala),but it failed.Could you give me help:)
ConnectPool.scala
class ConnectPool extends Serializable{
private val cpds: ComboPooledDataSource = new ComboPooledDataSource(true)
private val conf = Utils.getPropmap("env.properties")
try {
cpds.setJdbcUrl(conf("kudu.produce.url"))
cpds.setDriverClass(conf("jdbc.driver"))
cpds.setMaxPoolSize(400)
cpds.setMinPoolSize(20)
cpds.setAcquireIncrement(5)
cpds.setMaxStatements(380)
} catch {
case e: Exception => e.printStackTrace()
}
def getConnection: Connection = {
try {
return cpds.getConnection()
} catch {
case ex: Exception =>
ex.printStackTrace()
null
}
}
}
object ConnectManager {
var kuduManager: ConnectPool = _
def getConnectManager: ConnectPool = {
synchronized {
if (kuduManager == null) {
kuduManager = new ConnectPool
}
}
kuduManager
}
}
main.scala
messages.foreachRDD(rdd => {
val conn = ConnectManager.getConnectManager.getConnection
val stmt = conn.createStatement
if(!rdd.isEmpty() && rdd.count() >0){
//初始化spark
val spark = SparkSession.builder.config(rdd.sparkContext.getConf).getOrCreate()
try{
// use stmt
}catch {
case e: Exception => print("\ntest\n")
} finally {
stmt.close()
conn.close()}
}
})
out put
18/03/16 16:56:00 INFO c3p0.SQLWarnings:
[Simba]ImpalaJDBCDriver Error setting default connection
property values: {0} java.sql.SQLWarning:
[Simba]ImpalaJDBCDriver Error setting default connection
property values: {0}
at com.cloudera.jdbc.common.SWarningListener.createSQLWarning(Unknown
Source)
at com.cloudera.jdbc.common.SWarningListener.postWarning(Unknown Source)
at com.cloudera.jdbc.common.SConnection.(Unknown Source)
at com.cloudera.jdbc.common4.C4SConnection.(Unknown Source)
at com.cloudera.jdbc.jdbc41.S41Connection.(Unknown Source)
at com.cloudera.impala.jdbc41.ImpalaJDBC41Connection.(Unknown
Source)
at com.cloudera.impala.jdbc41.ImpalaJDBC41ObjectFactory.createConnection(Unknown
Source)
at com.cloudera.jdbc.common.BaseConnectionFactory.doConnect(Unknown
Source)
at com.cloudera.jdbc.common.AbstractDriver.connect(Unknown Source)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:119)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:143)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:132
The output you are seeing is a warning, not an error. c3p0 resets and prints any warnings that a Connection experiences prior to checking them back into the pool. This surprises developers sometimes, as very few developers bother to check for warnings, and so they often go unnoticed.
I don't know what this warning means, exactly. But JDBC Connection warnings often occur for nonserious conditions. Is your application working properly, besides the warning output?
If you decide you can live with the warnings, you can redirect them or shut them down by configuring the special logger com.mchange.v2.c3p0.SQLWarnings. Setting the log level of this logger to anything more severe than INFO will prevent the appearance of these messages.

what APIs are available to connect to IBM websphere MQ

I have a requirement, where I need to use IBM websphere message queue pub sub functionality.
Basically I have to write the subscriber part.
I need to know what all programming languages I can use to write the API other than java.
Can I write it using perl/shell/python?
There is PyMQI available for Python lovers. But note this offering is NOT from IBM.
Use MQ Client API. It does include samples for C++ like this one:
int main ( int argc, char * * argv ) {
ImqQueueManager mgr; // Queue manager
ImqQueue queue; // Queue
ImqMessage msg; // Data message
ImqGetMessageOptions gmo; // Get message options
char buffer[ 101 ]; // Message buffer
ImqChannel * pchannel = 0 ; // Channel definition
printf( "Sample IMQSGET start\n" );
if ( argc < 2 ) {
printf( "Required parameter missing - queue name\n" );
exit( 99 );
}
// Create object descriptor for subject queue
queue.setName( argv[ 1 ] );
if ( argc > 2 ) {
mgr.setName( argv[ 2 ] );
}
// Define a channel for client communication.
if ( argc > 3 ) {
ImqString strParse( argv[ 3 ] );
ImqString strToken ;
pchannel = new ImqChannel ;
pchannel -> setHeartBeatInterval( 1 );
// Break down the channel definition,
// which is of the form "channel-name/transport-type/connection-name".
if ( strParse.cutOut( strToken, '/' ) ) {
pchannel -> setChannelName( strToken );
if ( strParse.cutOut( strToken, '/' ) ) {
// Interpret the transport type.
if ( strToken.upperCase( ) == (ImqString)"LU62" ) {
pchannel -> setTransportType( MQXPT_LU62 );
}
if ( strToken.upperCase( ) == (ImqString)"NETBIOS" ) {
pchannel -> setTransportType( MQXPT_NETBIOS );
}
if ( strToken.upperCase( ) == (ImqString)"SPX" ) {
pchannel -> setTransportType( MQXPT_SPX );
}
if ( strToken.upperCase( ) == (ImqString)"TCP" ) {
pchannel -> setTransportType( MQXPT_TCP );
}
// Establish the connection name.
if ( strParse.cutOut( strToken ) ) {
pchannel -> setConnectionName( strToken );
}
}
}
mgr.setChannelReference( pchannel );
}
// Connect to queue manager
if ( ! mgr.connect( ) ) {
/* stop if it failed */
printf( "ImqQueueManager::connect failed with reason code %ld\n",
(long)mgr.reasonCode( ) );
exit( (int)mgr.reasonCode( ) );
}
// Associate queue with queue manager.
queue.setConnectionReference( mgr );
// Open the named message queue for input; exclusive or shared
// use of the queue is controlled by the queue definition here
queue.setOpenOptions(
MQOO_INPUT_AS_Q_DEF /* open queue for input */
+ MQOO_FAIL_IF_QUIESCING
); /* but not if MQM stopping */
queue.open( );
/* report reason, if any; stop if failed */
if ( queue.reasonCode( ) ) {
printf( "ImqQueue::open ended with reason code %ld\n",
(long)queue.reasonCode( ) );
}
if ( queue.completionCode( ) == MQCC_FAILED ) {
printf( "unable to open queue for input\n" );
}
// Get messages from the message queue
// Loop until there is a failure
msg.useEmptyBuffer( buffer, sizeof( buffer ) - 1 );
/* buffer size available for GET */
gmo.setOptions( MQGMO_WAIT | /* wait for new messages */
MQGMO_FAIL_IF_QUIESCING );
gmo.setWaitInterval( 15000 ); /* 15 second limit for waiting */
while ( queue.completionCode( ) != MQCC_FAILED ) {
// In order to read the messages in sequence, MsgId and
// CorrelID must have the default value. MQGET sets them
// to the values in for message it returns, so re-initialise
// them before every call
msg.setMessageId( );
msg.setCorrelationId( );
if ( queue.get( msg, gmo ) ) {
// Display each message received
if ( msg.formatIs( MQFMT_STRING ) ) {
buffer[ msg.dataLength( ) ] = 0 ; /* add terminator */
printf( "message <%s>\n", msg.bufferPointer( ) );
} else {
printf( "Non-text message\n" );
}
} else {
/* report reason, if any */
if ( queue.reasonCode( ) == MQRC_NO_MSG_AVAILABLE ) {
/* special report for normal end */
printf( "no more messages\n" );
} else {
/* general report for other reasons */
printf( "ImqQueue::get ended with reason code %ld\n",
(long)queue.reasonCode( ) );
/* treat truncated message as a failure for this sample */
if ( queue.reasonCode( ) == MQRC_TRUNCATED_MSG_FAILED ) {
break ;
}
}
}
}
// Close the source queue (if it was opened)
if ( ! queue.close( ) ) {
/* report reason, if any */
printf( "ImqQueue::close failed with reason code %ld\n",
(long)queue.reasonCode( ) );
}
// Disconnect from MQM if not already connected (the
// ImqQueueManager object handles this situation automatically)
if ( ! mgr.disconnect( ) ) {
/* report reason, if any */
printf( "ImqQueueManager::disconnect failed with reason code %ld\n",
(long)mgr.reasonCode( ) );
}
// Tidy up the channel object if allocated.
if ( pchannel ) {
mgr.setChannelReference( );
delete pchannel ;
}
printf( "Sample IMQSGET end\n" );
return( 0 );
}
IBM offers MQ clients for the following languages:
C, C++, .NET, Java
WebSphere MQ provides support for the following programming procedural languages:
C
Visual Basic (Windows systems only)
COBOL
Assembler language (WebSphere MQ for z/OS® only)
RPG (WebSphere MQ for IBM® i only)
PL/I (WebSphere MQ for z/OS only)
These languages use the message queue interface (MQI) to access message queueing services.
WebSphere MQ provides support for:
.NET
ActiveX
C++
Java
JMS
These languages use the WebSphere MQ Object Model, which provides classes that provide the same functionality as WebSphere MQ calls and structure.
Fuente

boost deadline_timer not kicking off

We have written a single threaded client based on the boost asio. The client needs to implement a timeout, so that the connection is broken if the read or write from server was not completed in a stipulated time period. But the async_wait for the deadline_timer does not kick off untill I don't call run for the io_service. Now if I call run on the io_service then my reading and writing to the server is not possible.
Please see the excerpts from my current code:
typedef boost::scoped_ptr<boost::asio::ip::tcp::socket> SocketPtr;
typedef boost::shared_ptr<boost::asio::deadline_timer> DLTPtr;
SocketPtr m_SocketPtrClient;
DLPtr m_ClientTimeoutDLTPtr;
boost::asio::io_service ios;
m_SocketPtrClient.reset( new boost::asio::ip::tcp::socket( ios));
m_ClientTimeoutDLTPtr.reset( new deadline_timer( ios));
m_ClientTimeoutDLTPtr->expires_from_now( boost::posix_time::seconds( m_uiCommTimeout));
m_ClientTimeoutDLTPtr->async_wait( boost::bind( &MyClass::clientTimeoutHandler,
this,
boost::asio::placeholders::error
)
);
m_SocketPtrClient->connect
(
boost::asio::ip::tcp::endpoint
(
boost::asio::ip::address::from_string
(
m_sCommAddress == "localhost" ? "127.0.0.1" : m_sCommAddress
), m_usCommPort
), ec
);
if( !ec && m_SocketPtrClient->is_open())
{
m_ClientTimeoutDLTPtr->cancel();
}
else
{
m_ClientTimeoutDLTPtr->cancel();
m_SocketPtrClient->close();
return eStateError;
}
//install a timeout handler
m_ClientTimeoutDLTPtr->expires_from_now( boost::posix_time::seconds( m_uiCommTimeout));
m_ClientTimeoutDLTPtr->async_wait( boost::bind( &MyClass::clientTimeoutHandler,
this,
boost::asio::placeholders::error
)
);
ec = writeToServer( *m_SocketPtrClient);
if( ec)
{
// do error handling and throw an exception
}
m_ClientTimeoutDLTPtr->cancel();
//install a timeout handler
m_ClientTimeoutDLTPtr->expires_from_now( boost::posix_time::seconds( m_uiCommTimeout));
m_ClientTimeoutDLTPtr->async_wait( boost::bind( &MyClass::clientTimeoutHandler,
this,
boost::asio::placeholders::error
)
);
ec = readFromServer( *m_SocketPtrClient);
if( ec)
{
// do error handling and throw an exception
}
m_ClientTimeoutDLTPtr->cancel();
void MyClass::clientTimeoutHandler( const boost::system::error_code& ec)
{
if( ec)
{
m_ClientTimeoutDLTPtr->cancel();
m_SocketPtrClient->close();
m_ssMsg << std::endl << "break all handling because of timeout on io_service of Client!";
}
else
{
m_ClientTimeoutDLTPtr->expires_from_now( boost::posix_time::seconds( m_uiCommTimeout));
m_ClientTimeoutDLTPtr->async_wait( boost::bind( &MyClass::clientTimeoutHandler,
this,
boost::asio::placeholders::error
)
);
}
}
I need to connect, write to the server and then get response from the server and for each operation I need the timeout to kickoff. If I call the run from io_service then I can't make my these three calls.
I need to connect, write to the server and then get response from the
server and for each operation I need the timeout to kickoff. If I call
the run from io_service then I can't make my these three calls.
When using deadline_timer::async_wait() you will need to use the corresponding asynchronous socket methods such as socket::async_connect() instead of socket::connect().

Resources