Search code examples
javaibm-mqpcf

How does the PCFMessageAgent handle disconnecting?


I'm trying to get an understanding of how the PCFMessageAgent manages connections to ensure I'm cleaning up everything properly.

For example, at what point is the connection disconnected once I've created the object and I'm done with it?

PCFMessageAgent agent = new PCFMessageAgent ("localhost", 1414, "CLIENT");

The example in the documentation does not show any disconnect call, but I want to be sure I'm not assuming anything.

If it matters, I'm currently on MQ version 7.5, but it doesn't appear this has changed much.


Solution

  • Always cleanup your stuff.

    • If you connect it, then make sure you disconnect from it
    • If you open it, then make sure you close it

    i.e.

    if (agent != null)
       agent.disconnect();