首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JCA外键MessageEndpoint大小

JCA外键MessageEndpoint大小
EN

Stack Overflow用户
提问于 2021-02-17 17:30:22
回答 1查看 55关注 0票数 0

我希望在Liberty应用程序服务器上使用自己的自定义JCA出站适配器发送多个出站消息。

这是我的资源适配器:

代码语言:javascript
复制
@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托管连接:

代码语言:javascript
复制
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个请求时,我收到此异常:

代码语言:javascript
复制
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适配器线程池?

EN

回答 1

Stack Overflow用户

发布于 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/ResourceAdapterExampleResourceAdapter是单例的,所以如果你有重叠的executeRequest,它会覆盖endpointTarget,并且只有一个会在endpointDeactivation中发布。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66239146

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档