Search code examples
javamulemule-el

Create and set Connector dynamically for endpoint


I have an outbound-endpoint, but I would like to create and set a connector dynamically for the endpoint using Java, before the endpoint actually sends a file.

I have found an example on creating a connector dynamically, as in:

    As2Connector connector = new As2Connector(muleContext);
    connector.setName("TestAS2Connector");
    connector.setPartnerId("mend");
    connector.setKeystorePath("src/test/resources/keystoreTest.jks");
    connector.setKeystorePassword("PASSWORD");
    return connector;

However, I do not know how to tie the connector with my existing endpoint. Is there a way to do this?

Thank you,


Solution

  • Let the MuleClient create the endpoint for you and configure the connector on it, like:

    muleClient.send("as2://...?connector=TestAS2Connector", ...);