My MQIC.pas for Delphi 2009 you can download from here. File you will find in the rar.

If you are receiving error Reason code:2102 - MQRC_RESOURCE_PROBLEM, then try following:

Increase Log -> Log primary files and Log -> Log secondary files, to 20, for example,
Increase Extended -> Error log size.

Idea taken from here.

There are two posibillity to start transaction:

1. MQBegin - Queue-manager-coordinated global unit of work
2. MQPMO_SYNCPOINT - Queue-manager-coordinated local unit of work

MQBegin is trivial, so I will not explain it.

For MQPMO_SYNCPOINT you have to do something like

GetMsgOptions.Options:=GetMsgOptions.Options + MQPMO_SYNCPOINT;

Where  GetMsgOptions you use like:

MQGET ( Hconn, Hobj, @MsgDesc, @GetMsgOptions, BufferLength, @Buffer^, @DataLength, @intCompcode, @intReason);

In both cases you will use MQCMIT, and MQBACK to commit or reverse transaction back.

Taken from here.

Question is, how to browse messages, without deleting them from MQ?

I did it with Delphi.

You will need to change GetMsgOptions, at me it is like:

MQGMO_DEFAULT : MQGMO = (StrucId:MQGMO_STRUC_ID;
  Version:MQGMO_VERSION_1;
 Options:MQGMO_NO_WAIT;
  WaitInterval:0;
  Signal1:0;
  Signal2:0;
  ResolvedQName:#0;
  MatchOptions:(MQMO_MATCH_MSG_ID+MQMO_MATCH_CORREL_ID);
  GroupStatus:MQGS_NOT_IN_GROUP;
  SegmentStatus: MQSS_NOT_A_SEGMENT;
  Segmentation:MQSEG_INHIBITED;
  Reserved1:' ';
  MsgToken:($0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0);
  ReturnedLength:MQRL_UNDEFINED;
  );

In MQIC.pas which I downloaded it from here, I changed MQGMO_DEFAULT to:

MQGMO_DEFAULT : MQGMO = (StrucId:MQGMO_STRUC_ID;
  Version:MQGMO_VERSION_1;
  Options:(MQGMO_BROWSE_NEXT + MQGMO_NO_WAIT);
  WaitInterval:0;
  Signal1:0;
  Signal2:0;
  ResolvedQName:#0;
  MatchOptions:(MQMO_MATCH_MSG_ID+MQMO_MATCH_CORREL_ID);
  GroupStatus:MQGS_NOT_IN_GROUP;
  SegmentStatus: MQSS_NOT_A_SEGMENT;
  Segmentation:MQSEG_INHIBITED;
  Reserved1:' ';
  MsgToken:($0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0);
  ReturnedLength:MQRL_UNDEFINED;
);

I added MQGMO_BROWSE_NEXT, but, before geting messages, you will need to open MQ for browsing messages, you will do it like this:

Open(MQOO_FAIL_IF_QUIESCING + MQOO_INPUT_SHARED + MQOO_BROWSE, strObjectName, intReason, bolOk);

And that is all...

Subcategories