我希望在Liberty应用程序服务器上使用自己的自定义JCA出站适配器发送多个出站消息。
这是我的资源适配器:
@Connector(description = "Example Resource Adapter", displayName = "Example Resource Adapter", eisType = "Example Resource Adapter", version = "1.0")
public class ExampleResourceAdapter implements ResourceAdapter {
private EndpointTarget endpointTarget;
private MessageEndpointFactory messageEndpointFactory;
public void start(BootstrapContext bootstrapContext) {
}
public void stop() {
}
public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec) {
this.messageEndpointFactory = messageEndpointFactory;
}
public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
if (endpointTarget != null) {
endpointTarget.getMessageEndpoint().release();
}
}
public XAResource[] getXAResources(ActivationSpec[] activationSpecs) {
return new XAResource[0];
}
public void executeRequest(String iid) {
endpointTarget = new EndpointTarget(messageEndpointFactory, iid);
endpointTarget.start();
} 这是jca托管连接:
public class ExampleManagedConnection implements ManagedConnection {
private static Logger log = Logger.getLogger(ExampleManagedConnection.class.getName());
private PrintWriter logwriter;
private ExampleManagedConnectionFactory mcf;
private List<ConnectionEventListener> listeners;
private ExampleConnectionImpl connection;
public ExampleManagedConnection(ExampleManagedConnectionFactory mcf) {
this.mcf = mcf;
this.logwriter = null;
this.listeners = Collections.synchronizedList(new ArrayList<>(1));
this.connection = null;
}
public Object getConnection(Subject subject,
ConnectionRequestInfo cxRequestInfo) throws ResourceException {
log.finest("getConnection()");
connection = new ExampleConnectionImpl(this, mcf);
return connection;
}
public void associateConnection(Object connection) throws ResourceException {
log.finest("associateConnection()");
if (connection == null)
throw new ResourceException("Null connection handle");
if (!(connection instanceof ExampleConnectionImpl))
throw new ResourceException("Wrong connection handle");
this.connection = (ExampleConnectionImpl) connection;
}
public void cleanup() throws ResourceException {
log.finest("cleanup()");
}
public void destroy() throws ResourceException {
log.finest("destroy()");
}
public void addConnectionEventListener(ConnectionEventListener listener) {
log.finest("addConnectionEventListener()");
if (listener == null) {
throw new IllegalArgumentException("Listener is null");
}
listeners.add(listener);
}
public void removeConnectionEventListener(ConnectionEventListener listener) {
log.finest("removeConnectionEventListener()");
if (listener == null)
throw new IllegalArgumentException("Listener is null");
listeners.remove(listener);
}
public PrintWriter getLogWriter() throws ResourceException {
log.finest("getLogWriter()");
return logwriter;
}
public void setLogWriter(PrintWriter out) throws ResourceException {
log.finest("setLogWriter()");
logwriter = out;
}
public LocalTransaction getLocalTransaction() throws ResourceException {
throw new NotSupportedException("getLocalTransaction() not supported");
}
public XAResource getXAResource() throws ResourceException {
throw new NotSupportedException("getXAResource() not supported");
}
public ManagedConnectionMetaData getMetaData() throws ResourceException {
log.finest("getMetaData()");
return new ExampleManagedConnectionMetaData();
}
public void getPreTimeMarketOrders(String iid) {
ExampleResourceAdapter ExampleResourceAdapter = (ExampleResourceAdapter) mcf.getResourceAdapter();
ExampleResourceAdapter.executeRequest(iid);
}
} 当发送超过500个请求时,我收到此异常:
javax.resource.spi.RetryableUnavailableException: limit for number of MessageEndpoint proxies reached. Limit = 500
at com.ibm.ws.ejbcontainer.mdb.BaseMessageEndpointFactory.createEndpoint(BaseMessageEndpointFactory.java:349)
at com.ibm.ws.ejbcontainer.mdb.internal.MessageEndpointFactoryImpl.createEndpoint(MessageEndpointFactoryImpl.java:385) 如何在Liberty/OpenLiberty Application Server中更改JCA适配器线程池?
发布于 2021-02-17 23:03:45
查看OpenLiberty源代码,500是在没有其他配置的情况下使用的默认值。
看起来您可以为一种bean类型配置不同的最大池大小。请参阅介绍this document中的com.ibm.websphere.ejbcontainer.poolSize的一节。
也就是说,您的方法似乎有点不合常规,因为MessageEndpointFactory旨在用于入站通信,而不是出站通信。入站通信涉及一个消息驱动的Bean来接收入站消息(可以为其配置一个com.ibm.websphere.ejbcontainer.poolSize )。
您在executeRequest中覆盖endpointTarget的方法也是可疑的。@Connector/ResourceAdapter类ExampleResourceAdapter是单例的,所以如果你有重叠的executeRequest,它会覆盖endpointTarget,并且只有一个会在endpointDeactivation中发布。
https://stackoverflow.com/questions/66239146
复制相似问题