when we connect the MQ using MQ Explorer we are getting different message and when we connect from RFH Util we are getting different message.
From java we can see the message is coming as com.ibm.jms.JMSMessage.
MQ Explorer:
enter image description here
RFH Util:
enter image description here
RFH Util is giving correct value.
My question is, if we use our java code how we can get the correct value? currently we are getting the wrong value in java.
Expected is "!" but in MQ Explorer and java we are getting is "|".
Messages are coming from : Mainframe -> MQ -> java
it can be an encryption problem,
if (message instanceof TextMessage) {
TextMessage aTextMessage = (TextMessage) message;
System.out.println(aTextMessage.getText());
Your problem is likely due to data conversion rather than encryption. Are both of your clients connecting from the same machine? You should check how the data conversion is being done. You may also wish to review the MQ knowledge center.
Hi we are able to resolve the issue, from the screenshots we understood that java is expecting EBSIDIC character set, so we change the corrector set to EBSIDIC (“037”) from Mainframe and it resolve the issue.
Mainframe changes : FUNCTION DISPLAY-OF (WS-AREA, 037)
Earlier it was FUNCTION DISPLAY-OF (WS-AREA, 500)
Thanks.
Related
I am coding a forge minecraft 1.12.2 mod and I need to know how do I get the contents of a chat message that someone sends in chat.
I am using the ServerChatEvent event to sence messages but I do not know how to get the actual content of the message itself.
To get the message you can use :
event.getMessage();
Also, if you want the full message (with style/actions/...) you can use :
event.getComponent()
More informations:
Javadoc
Few examples
I'm trying to create communication between simple Java App (using java.net.http.WebSocket class) and remote google-chrome run using google-chrome --remote-debugging-port=9222 --user-data-dir=.
Sending and receiving small messages works as expected, but there is an issue in case of bigger messages, 16kb.
Here is part of java source:
var uri = new URI("ws://127.0.0.1:9222/devtools/page/C0D7B4DBC53FB39F7A4BE51DA79E96BB");
/// create websocket client
WebSocket ws = HttpClient
.newHttpClient()
.newWebSocketBuilder()
.connectTimeout(Duration.ofSeconds(30))
.buildAsync(uri, simpleListener)
.join();
// session Id attached to chrome tab
String sessionId = "...";
// send message
String message = "{\"id\":1,\"method\":\"Runtime.evaluate\",\"params\":{\"expression\":\"document.body.style.backgroundColor = 'blue';\",\"returnByValue\":true,\"awaitPromise\":true,\"userGesture\":true},\"sessionId\":\"" + sessionId + "\"}";
// this works
ws.send(message, true);
// generate big string contains over 18k chars for testing purpose
String bigMessage = "{\"id\":2,\"method\":\"Runtime.evaluate\",\"params\":{\"expression\":\"[" + ("1,".repeat(9000)) + "1]\",\"returnByValue\":true,\"awaitPromise\":true,\"userGesture\":true},\"sessionId\":\"" + sessionId + "\"}";
// this doesn't work
ws.send(bigMessage, true);
Here is stack:
java.net.SocketException: Connection reset
at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:345)
at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:376)
at java.net.http/jdk.internal.net.http.SocketTube.readAvailable(SocketTube.java:1153)
at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.read(SocketTube.java:821)
at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowTask.run(SocketTube.java:175)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
...
I've tried basically the same by using puppeteer (nodejs library) and it works as expected.
I can't find any resource online about this issue.
Is there anything I'm missing in my example?
Here is url to simple example:
https://github.com/zeljic/websocket-devtools-protocol
Based on what I've seen so far, my best guess would be that Chrome Dev Tools do not process fragmented Text messages on that exposed webSocketDebuggerUrl endpoint. Whether Chrome Dev Tools can be configured to do so or not, is another question. I must note, however, that RFC 6455 (The WebSocket Protocol) mandates it:
Clients and servers MUST support receiving both fragmented and unfragmented messages.
There's one workaround I can see here. Keep in mind that this is unsupported and may change in the future unexpectedly. When running your client, specify the following system property on the command line -Djdk.httpclient.websocket.intermediateBufferSize=1048576 (or pick any other suitable size). As long as you keep sending your messages with true passed as boolean last argument to the send* methods, java.net.http.WebSocket will send messages unfragment, in a single WebSocket frame.
Well I had a similar issue when sending a big string by using web-sockets in java with a tomcat server.
There can be payload limit to send or receive in websocket server .
checkout org.apache.tomcat.websocket.textBufferSize in tomcat's doc. By default it is 8192 bytes try increasing the size.
I am in a bit of a bind. I am trying to read a message of a WMQ via jms and then convert it to a pcf message for processing. I have only been able to find one resource on this and it hasn't been very helpful [bottom of http://www-01.ibm.com/support/docview.wss?uid=swg21395682 ]
I have tried to implement the technique in the above doc but every time I get to line
PCFMessage response = new PCFMessage(dataInput);
I throw MQRC 3013 - MQRCCF_STRUCTURE_TYPE_ERROR
This is the way my code looks, maybe you can see something I don't.
BytesMessage message = null;
do {
// The consumer will wait 10 seconds (10,000 milliseconds)
message = (BytesMessage) myConsumer.receive(10000);
// get the size of the bytes message & read into an array
int bodySize = (int) message.getBodyLength();
byte[] data = new byte[bodySize];
message.readBytes(data, bodySize);
// Read into Stream and DataInput Stream
ByteArrayInputStream bais = new ByteArrayInputStream(data);
DataInput dataInput = new DataInputStream(bais);
// Pass to PCF Message to process
//MQException.logExclude(new Integer(2079));
PCFMessage qStatsPcf = new PCFMessage(dataInput);
session.commit();
if (message != null) {
processMessage(qStatsPcf);
}
} while (message != null);
myConsumer.close();
A couple updates in response to T.Rob's answer.
I am currently running MQ 7.0. This is a what it is type thing, I can't currently upgrade.
As to what I am trying to do, I am pulling messages from SYSTEM.ADMIN.STATISTICS.QUEUE and I want to parse that information for auditing purposes. The reasoning behind converting to a PCF message is that I am looking to pull some PCF parameters from these messages - for example .getParameter(PCFConstants.MQIAMO_PUTS)
I am not attempting to send messages to MQ in anyway, just pull messages off and process them.
A couple problems with this question:
There is no mention of the version of the version of MQ jms client that is in use. Since IBM has repackaged the Java/JMS classes several times, it is necessary to mention which version you are working with to get a better answer.
It is unclear what it is you are trying to do. An MQ PCF message is processed by the MQ Command Server. The messages are a binary format consisting of a linked list of name/type/value tuples. If your message body is not already in PCF name/type/value format, then casting it as a PCF message is expected to fail.
Since it is not possible to respond to the question as worded with a solution, I'll provide some recommendations based on wild guesses as to what it is you might be trying to do.
Use a modern MQ client. The Technote you linked to is for out-of-support versions of MQ client. You want one that is at least MQ v7.1, but preferably v8.0. since any version of MQ client works with any version of MQ, use the version that is most current. Just remember, the functionality you get is based on the oldest version of MQ used at the client or server. A v8.0 client doesn't get you v8.0 function on a v7.0 QMgr. Go to the SupportPacs page and look for entries with names like MQC**. The MQ v8.0 client is current and it is SupportPac MQC8.
If you really are trying to submit PCF messages to MQ's command processor, instantiate a PCF Agent to do it. Then construct the PCF message using one of the PCF message constructors that lets you specify the selectors and their values.
What happened when you tried using the PCF Java samples? Did they also fail? Did they work? If so, how does your code differ? You did look at IBM's PCF samples, right? Please see Installation directories for samples for the location for the sample programs, including the PCF samples.
If you are not attempting to send messages to the MQ Command Processor, please update the question to let us know what it is you are trying to do and why you believe you need PCF messages to do it.
my 2 cents...
Why are you using JMS to retrieve PCF Messages?
MQ Java is best placed to handle all statistics and event message. My suggestion is go with MQQueueManager object and retrieve a MQMessage out of SYSTEM.ADMIN.STATISTICS.QUEUE and pass it to PCFMessage constructor.
I have not compiled or tested the following, but it gives an outline.
//no try catch block to keep it simple
//assumed MQQueueManager (qmgr object) is already created
//assumed statQueue is available through qmgr.accessQueue() method
do {
MQMessage message = new MQMessage();
//gmo as CMQC.MQGMO_FAIL_IF_QUIESCING | CMQC.MQGMO_WAIT | CMQC.MQGMO_SYNCPOINT | CMQC.MQGMO_CONVERT;
message = statQueue.get(message, gmo);
// Pass to PCF Message to process
PCFMessage qStatsPcf = new PCFMessage(message);
qmgr.commit();
if (message != null) {
processMessage(qStatsPcf);
}
} while (message != null);
statQueue.close();
qmgr.close();
I'm building a client for trading with a remote server using FIX protocol and QuickFix/J API.
I can send order, receive price updates, cancel orders etc...
I'm asked now to "query API for current position of an instrument".
So let's say I can submit an order for buying an instrument, and it doesn't get executed, I would like to receive from the server some information like "you are LONG on intrument X with quantity Y etc".
Is it possible using QuickFix/J API?
I have written a method like this
static void positionReport() throws SessionNotFound{
quickfix.fix50.PositionReport order = new quickfix.fix50.PositionReport();
SessionID sessionId = (SessionID) initiator.getSessions().get(0);
order.set(new Account("1005390"));
order.set(new SecurityID("4663789"));
order.set(new SecurityExchange("XETR"));
order.set(new Symbol("SAP"));
Session.sendToTarget(order, sessionId);
}
which sends FIX messages like this
8=FIX.4.29=9835=AP34=4949=HIQ6_ORDER52=20140324-
15:54:10.14256=HIQFIX1=100539048=466378955=SAP207=XETR10=199
and receives messages like this:
8=FIX.4.29=9935=334=6949=HIQFIX52=20140324-15:54:10.89156=HIQ6_ORDER45=4958=Invalid
MsgType372=AP373=1110=242
As you can see I get "Invalid message" error
Check your counterparty's documentation.
FIX is a fairly "dumb" protocol. It just provides a communication infrastructure. The default message definitions are best thought of as a list of suggested messages that you can use. Even if one message type is supported by two counterparties, it's possible that each of the two counterparties could use it in totally different ways.
Most connection providers only use a subset of these messages. You should check their documentation to see if they support the PositionRequest message, and to see how they want you to set the fields in it.
No you cannot do that using Quickfix, unless and until the counterparty is modelled to give you FIX acknowledgements to your specific liking. That is why you can add your customized FIX fields to the FIX XML config file.
373 tag says 11 -> 11 = Invalid MsgType
58 confirms it for you again.
Check your FIX XML config and check if your message is complete and if your counterparty allows the messages of type AP.
Calling all MQ Gurus,
I have a box under my desk which we use to replicate our production environment which is:
WebSphere 6.1
Fedora Linux
MQ 6.0
Whenever one of our applications tries to send a message to a MQ queue we get the following error: MQJE018: Protocol error - unexpected segment type received
Any suggestions on what this might mean would be appreciated, stack traces are below.
Dump of callerThis =
Object type = com.ibm.ejs.jms.listener.MDBListenerImpl
com.ibm.ejs.jms.listener.MDBListenerImpl#744c744c
==> Performing default dump from com.ibm.ejs.jms.JMSDiagnosticModule = Wed May 06 13:09:58 BST 2009
Dump of callerThis =
Object type = com.ibm.ejs.jms.listener.MDBListenerImpl
com.ibm.ejs.jms.listener.MDBListenerImpl#744c744c
Linked exception = com.ibm.mq.MQException: MQJE001: An MQException occurred: Completion Code 2, Reason 2195
MQJE018: Protocol error - unexpected segment type received
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:238)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:318)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:338)
at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:84)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:168)
at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:774)
at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:690)
at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:646)
at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:153)
at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:544)
at com.ibm.mq.MQSPIQueueManager.<init>(MQSPIQueueManager.java:69)
at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:2401)
at com.ibm.mq.jms.MQConnection.createQMXA(MQConnection.java:1783)
at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:110)
at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:67)
at com.ibm.mq.jms.MQXAQueueConnection.<init>(MQXAQueueConnection.java:57)
at com.ibm.mq.jms.MQXAQueueConnectionFactory.createXAQueueConnection(MQXAQueueConnectionFactory.java:80)
EDIT:I have looked up the reason codes in the IBM documentation which gives little help
2195 (X'0893')
MQRC_UNEXPECTED_ERROR
Explanation:
The call was rejected because an unexpected error occurred.
Completion Code:
MQCC_FAILED
Programmer Response:
Check the application's parameter list to ensure, for example, that the correct number of parameters was passed, and that data pointers and storage keys are valid. If the problem cannot be resolved, contact your system programmer.
* On z/OS, check whether any information has been displayed on the console. If this error occurs on an MQCONN or MQCONNX call, check that the subsystem named is an active MQ subsystem. In particular, check that it is not a DB2(TM) subsystem. If the problem cannot be resolved, rerun the application with a CSQSNAP DD card (if you have not already got a dump) and send the resulting dump to IBM.
* On OS/2 and i5/OS, consult the FFST record to obtain more detail about the problem.
* On HP OpenVMS, Compaq NonStop Kernel, and UNIX systems, consult the FDC file to obtain more detail about the problem.
OK, finally managed to get around this error. It was nothing to do with the MQ install its self. I knew it was some kind of network issue so I changed the host name settings within websphere from the hostname to the ip of the box and everything worked fine.
Note, I made the host name changes on the queues and on the queue connection factories.
Hope that helps someone.
Karl