Closed mehrdad2000 closed 2 months ago
@mehrdad2000 Sorry, but you have to provide more information than this. I can only guess that
JMSChannel
extends BaseChannel
as suggested here without calling its setConfiguration
.ChannelAdaptor
warning.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.
@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);
}
}
Hi I try to set some variables in "ISO8583 Connection Configuration" for custom channel but seems it doesn't pass variables to jpos!
in first line of log it show get host and other variables for channel-adaptor successfully, but in second line when start jpos-q2 seems doesn't pass variables to it! and return "hostname can't be null"
here is the log:
Any idea? Thanks