Giter Site home page Giter Site logo

Comments (2)

tilln avatar tilln commented on June 12, 2024 1

@mehrdad2000
Sorry, but you have to provide more information than this.
I can only guess that

  • this is in context of your other issue #73
  • against recommendation, for some unknown reason your JMSChannel extends BaseChannel as suggested here without calling its setConfiguration.
  • somehow, possibly because you don't override some method, your JMSChannel tries to make a socket connection and Java throws an exception which leads to the ChannelAdaptor warning.
  • the following disconnect would then disconnect your JMSChannel.

But those are only guesses.

In any case, the issue is unlikely to be caused by this plugin or the jPOS framework, but quite possibly your own implementation, unless you have thoroughly tested it, for which you have provided no indication, and rather outside JMeter as the jPOS community recommends as well).

Until you have done your due diligence, please stop spamming more issues, but use discussions or the jPOS-users group instead.

from jmeter-iso8583.

mehrdad2000 avatar mehrdad2000 commented on June 12, 2024 1

@tilln Thank you so much for your hints, after several workaround finally figure out what happen here. :))
call function setConfiguration as you mention missed.
also, after send request I should implement disconnect method.
Here is the final JMSChannel that work with jmeter-iso8583 plugin.

package org.jpos.iso.channel;

import com.ibm.jms.JMSTextMessage;
import com.ibm.mq.jms.*;
import com.ibm.msg.client.wmq.WMQConstants;
import org.jpos.iso.ISOChannel;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.BaseChannel;
import org.jpos.core.Configuration;
import org.jpos.core.Configurable;
import org.jpos.core.ConfigurationException;

import javax.jms.*;
import java.io.*;
public class JMSChannel extends BaseChannel implements ISOChannel, Configurable {
    private MQQueueConnectionFactory cf;
    private MQQueueConnection connection;
    private MQQueueSession session;
    private MQQueueSender sender;

    @Override
    public void setConfiguration(Configuration cfg) throws ConfigurationException {
        super.setConfiguration(cfg); // Call BaseChannel's setConfiguration
        try {
            cf = new MQQueueConnectionFactory();
            cf.setHostName(cfg.get("host"));
            cf.setPort(cfg.getInt("port"));
            cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
            cf.setQueueManager(cfg.get("queueManager"));
            cf.setChannel(cfg.get("channel"));
            cf.setStringProperty(WMQConstants.USERID, cfg.get("user"));
            cf.setStringProperty(WMQConstants.PASSWORD, cfg.get("pass"));

            connection = (MQQueueConnection) cf.createQueueConnection();
            session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
            MQQueue queue = (MQQueue) session.createQueue(cfg.get("qname"));
            sender = (MQQueueSender) session.createSender(queue);

            connection.start();

        } catch (JMSException e) {
            throw new ConfigurationException(e);
        }
    }

    @Override
    public void disconnect() throws IOException {
        try {
            if (sender != null) {
                sender.close();
            }
            if (session != null) {
                session.close();
            }
            if (connection != null) {
                connection.close();
            }
        } catch (JMSException e) {
            throw new IOException(e);
        }
    }

@Override
public void send(ISOMsg isoMsg) throws IOException, ISOException {
    try {
        // Set header (replace "0000" with your desired header value)
        Configuration cfg = getConfiguration();
        String headerValue = cfg.get("header");
        isoMsg.setHeader(headerValue.getBytes());

        //isoMsg.setHeader(cfg.get(headerValue)).getBytes()); // Replace "0000" with channelHeader

        // Convert the header to a string
        String headerStr = new String(isoMsg.getHeader());

        TextMessage jmsMsg = session.createTextMessage();
        // Append the header to the beginning of the message text
        jmsMsg.setText(headerStr + new String(isoMsg.pack()));

        sender.send(jmsMsg);
    } catch (JMSException e) {
        throw new IOException(e);
    }
}

from jmeter-iso8583.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.