Package com.ibm.mq

Examples of com.ibm.mq.MQMessage


  @Override
  public JComponent render(JScrollPane parent, final Message message) {
    JComponent rval = null;

    try {
      MQMessage mqMessage = admin.getMQMessage(message);

      final Map map = new LinkedHashMap();

      try {
        inspectMessage(map, mqMessage);
View Full Code Here


    }

    public void sendMessage(BridgeMsg msg) throws BridgeException {
        try {
            /* create MQ message */
            MQMessage mqMsg = new MQMessage();
            MQPutMessageOptions opt = new MQPutMessageOptions();
            opt.options = MQC.MQPMO_NEW_MSG_ID | MQC.MQPMO_NO_SYNCPOINT;
            mqMsg.messageFlags = MQC.MQMF_SEGMENTATION_ALLOWED;
            /* set message payload */
            switch (msg.getMsgType()) {
            case BridgeMsg.TYPE_NONE:
                /* no payload */
                mqMsg.format = MQC.MQFMT_NONE;
                break;
            case BridgeMsg.TYPE_BYTES:
                /* binary message */
                mqMsg.format = MQC.MQFMT_NONE;
                mqMsg.write(msg.getByteData());
                break;
            case BridgeMsg.TYPE_TEXT:
                /* text message */
                mqMsg.format = MQC.MQFMT_STRING;
                mqMsg.characterSet = 1208; /* UTF-8 */
                mqMsg.writeString(msg.getTextData());
                break;
            default:
                /* FIXME will cause message loops */
                throw new BridgeException("Message type " + msg.getMsgType() + " is not supported");
            }
View Full Code Here

    }

    public BridgeMsg receiveMessage() throws BridgeException {
        try {
            /* get MQ message */
            MQMessage mqMsg = new MQMessage();
            MQGetMessageOptions opt = new MQGetMessageOptions();
            opt.options = MQC.MQGMO_SYNCPOINT | MQC.MQGMO_ALL_SEGMENTS_AVAILABLE | MQC.MQGMO_COMPLETE_MSG | MQC.MQGMO_WAIT;
            opt.waitInterval = 4000; // this value should be smaller than what ChannelInstance.close allows for normal shutdown
            log.debug("queue.get() start");
            for (;;) {
                synchronized (stopping) {
                    if (stopping.value)
                        return null;
                }
                try {
                    queue.get(mqMsg, opt);
                    break;
                }
                catch (MQException ex) {
                    if (ex.reasonCode != MQException.MQRC_NO_MSG_AVAILABLE)
                        throw ex;
                }
            }
            log.debug("queue.get() returned");
            msgLog.logEarlyReceive(createBridgeMessageId(mqMsg.messageId));
            /* build bridge message */
            BridgeMsg msg = new BridgeMsg();
            /* message payload */
            if (mqMsg.format.equals(MQC.MQFMT_STRING)) {
                /* text message */
                msg.setMsgType(BridgeMsg.TYPE_TEXT);
                String textData = mqMsg.readStringOfByteLength(mqMsg.getDataLength());
                msg.setTextData(textData);
            }
            else {
                /* anything other is binary data */
                msg.setMsgType(BridgeMsg.TYPE_BYTES);
                int len = mqMsg.getDataLength();
                byte[] data = new byte[len];
                mqMsg.readFully(data);
                msg.setByteData(data);
            }
            /* message headers */
            msg.setMessageId(createBridgeMessageId(mqMsg.messageId));
            msg.setPersistence(createBridgePersistence(mqMsg.persistence));
View Full Code Here

TOP

Related Classes of com.ibm.mq.MQMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.