|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to create mixing type message |
« View previous topic :: View next topic » |
Author |
Message
|
Piker |
Posted: Wed Jun 19, 2002 9:51 am Post subject: How to create mixing type message |
|
|
Novice
Joined: 17 May 2002 Posts: 10
|
hi all :)
just a small question :)
I have csv-file and send the text row by row to a queue using MQPUT.
Now I want to create something like structure from each row
for example:
row - test;5;5.4
structure {char a[5], int b, double g} testStr;
and send this structure to a queue. After that I would parse the entire messages in Compute Node dealing with MRM messages, without any comma-delimeted text.
What should I do for it?
Sending this structure using (void*) casting is't right I suppose. Viewing the hex-message in mqseries explorer i see the wrong values.
Good luck.
Piker |
|
Back to top |
|
 |
kirani |
Posted: Wed Jun 19, 2002 10:11 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
If you are not setting byte alignment properly you may see wrong message size. Byte alignment can be set by setting some compiler option in your makefile or you can use #pragma in your code.
#pragma pack(1)
struct ...
#pragma pack()
in your code.
Once you populate structure with appropriate values, you cany copy that into buffer using memcpy before calling MQPUT function. You can first use memset function to get rid of low/junk values for uninitialized bytes.
Make sure you get rid of ; from your input record before using those values for creating structure. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
Piker |
Posted: Wed Jun 19, 2002 10:24 am Post subject: |
|
|
Novice
Joined: 17 May 2002 Posts: 10
|
do you mean I should copy into char buffer?
Good luck.
Piker |
|
Back to top |
|
 |
Piker |
Posted: Wed Jun 19, 2002 10:48 am Post subject: |
|
|
Novice
Joined: 17 May 2002 Posts: 10
|
Thank you for your answer :)
I had done everything (except memcpy)before. But unfortunately I didn't see double value(5.4) in the blob (with memcpy too).
How can I create the whole appropriate for MRM parser and provide the message with the whole values, with remainders? :)
Creating message I used MQFMT_STRING for Format
MQMI_NONE - MsgId
MQCI_NONE - CorrelId
Good luck.
Piker |
|
Back to top |
|
 |
kirani |
Posted: Wed Jun 19, 2002 10:55 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Piker,
i never used (void *) myself in MQPUT call, but I think it should work. Can you post your code here? _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
kirani |
Posted: Wed Jun 19, 2002 11:28 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
If you create a header file just with the structure and import into MRM, it will create message definition for you.
By looking at your strucutre I can say your message length is 17 bytes. Make sure your program is generating the same number of bytes. Since this is not a text message you should set MQMD.Format to MQFMT_NONE.
You should try parsing the input message using MRM to see whether proper values are populated in the message or not. You can use Trace node with ${Root} in it to print the parsed tree. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
Piker |
Posted: Wed Jun 19, 2002 11:23 pm Post subject: |
|
|
Novice
Joined: 17 May 2002 Posts: 10
|
I've decided to make the task a bit simpler.
char buffer[10000];
#pragma pack(1)
struct {int i,
char b[3],
float j,
double k;} testStr;
#pragma pack()
testStr.i = 4;
testStr.b[0] = 'f';
testStr.b[1] = 'g';
testStr.b[2] = '\0';
testStr.j = 4.35456;
testStr.k = 4.7;
memset((void*)buffer, '\0', sizeof(buffer));
memcpy((void*)buffer, (const void*)&testStr, sizeof(testStr));
MQCONN(QM_NAME, &Hcon, &CompCode, &CReason);
O_options = MQOO_OUTPUT + MQOO_FAIL_IF_QUIESCING;
MQOPEN(Hcon, &od, O_options, &Hobj, &OpenCode, &Reason);
memcpy(md.Format, MQFMT_NONE, (size_t)MQ_FORMAT_LENGTH);
memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId) );
memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId) );
MQPUT(Hcon, Hobj, &md, &pmo, sizeof(testStr),
(PMQVOID)buffer,&CompCode, &Reason);
......
blob of message is : 04 00 00 00 55 00 00 00
57 00 00 00 00 00 00 00
04 00 00 00 04 00 00 00
the length of this blob is 24
I expected the other values for testStr.j and testStr.k.
Having done message set describing this structure and prepared Input Node for MRM and my message set I didn't get the MRM message after parsing by that node.(in debug mode)
In debug mode I saw MQMD with completed properties and empty MRM side.
Good luck.
Piker
PS: trace node doesn't work with {$Root} pattern |
|
Back to top |
|
 |
kirani |
Posted: Thu Jun 20, 2002 6:40 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Piker,
Here is the sample code ..
Fie stud.h
Code: |
#pragma pack(1)
struct Student
{
char name[20];
int age;
};
#pragma pack()
|
File mqput.c
Code: |
//
// MQPUT.cpp - MQ Application
//
#include <cmqc.h> // MQ Header file
#include <stdio.h> // IO header
#include <string.h> // String functions
#include "stud.h"
int main(int argc, char *argv[])
{
MQHCONN hConn; // Connection handle
MQHOBJ hObject; // Object handle
MQCHAR48 qmgrName; // Name of queue manager
MQLONG iCompCode; // Completion code
MQLONG iReason; // Reason code qualifying CompCode
MQOD mqod = {MQOD_DEFAULT}; // Object description
MQMD mqmd = {MQMD_DEFAULT}; // Message Descriptor
MQPMO mqpmo = {MQPMO_DEFAULT}; // Put message options
MQLONG iMessageLen; // Messsage Length
MQBYTE buffer[1000]; // Message data buffer
Student stud;
Student *pstud = &stud;
if (argc < 3)
{
printf("Usage: Program queueName queueManagerName\n");
return(1);
}
strncpy(mqod.ObjectName, argv[1], MQ_Q_NAME_LENGTH); // Name of the queue
strncpy(qmgrName, argv[2], MQ_Q_MGR_NAME_LENGTH); // Name of the queue manager
strcpy(mqod.ObjectQMgrName, ""); // Use the connected QMgr
// MQCONN
MQCONN(qmgrName, // Queue manager
&hConn, // Connection handle
&iCompCode, // Completion code
&iReason); // Reason code
if (iCompCode == MQCC_FAILED)
{
printf("MQCONN failed with reason code %ld\n", iReason);
return(iReason);
}
MQLONG iOpenOptions = MQOO_OUTPUT | // Open queue for output
MQOO_FAIL_IF_QUIESCING; // but not if MQM stopping
// MQOPEN
MQOPEN(hConn, // connection handle
&mqod, // object descriptor for queue
iOpenOptions, // open options
&hObject, // object handle
&iCompCode, // MQOPEN completion code
&iReason); // reason code
if (iCompCode == MQCC_FAILED)
{
printf("MQOPEN failed with reason code %ld\n", iReason);
return(iReason);
}
// MQPUT
// TODO: Populate the message to be placed on the queue
memset(&stud.name,' ',20);
strncpy(stud.name,"Kiran",5);
stud.name[19] = '\0';
stud.age = 27;
memset(buffer,' ',1000);
memcpy(buffer,&stud,sizeof(stud));
iMessageLen = sizeof(stud);
mqpmo.Options |= MQPMO_NEW_MSG_ID; // generate a new MSGID
MQPUT(hConn, // connection handle
hObject, // object handle
&mqmd, // message descriptor
&mqpmo, // default options (datagram)
iMessageLen, // message length
buffer, // message buffer
&iCompCode, // completion code
&iReason); // reason code
if (iCompCode == MQCC_FAILED)
{
printf("MQPUT failed with reason code %ld\n", iReason);
return(iReason);
}
// MQCLOSE
MQCLOSE(hConn, &hObject, MQCO_NONE, &iCompCode, &iReason);
// MQDISC
MQDISC(&hConn, &iCompCode, &iReason);
return(0);
}
|
Sorry, I mistyped the expression for the Trace node. It should be
${Root}
I would recommend that you use RCD node to parse message instead of parsing it in the MQInput node itself. Attach another trace node to the catch terminal of MQInput node and print ${ExceptionList} in it. This will help us in resolving errors. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
Piker |
Posted: Fri Jun 21, 2002 4:16 am Post subject: |
|
|
Novice
Joined: 17 May 2002 Posts: 10
|
Why could RCD produce output message with empty MRM body?
I created message set and message with identifier m_test (message type). :( |
|
Back to top |
|
 |
Piker |
Posted: Sat Jun 22, 2002 4:09 am Post subject: |
|
|
Novice
Joined: 17 May 2002 Posts: 10
|
Nevermind :)
Thank you very much for your help.
Everything works perfectly.
Good luck.
Piker |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|