0

たくさんのスレッドがあり、それぞれがセッションを作成してorg.apache.qpid.client.AMQConnectionからセッションを作成します。

public void run() {
    Connection connection = new AMQConnection("amqp://*******:*****@clientid/test?brokerlist='tcp://********:****?sasl_mechs='ANONYMOUS''");
    connection.start();

    Session ssn = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);    
    System.out.println(ssn.toString());

    ssn.close();
    connection.close();
}

一部の実行では、次のように2つの異なるスレッドで同じSession.hashCode()を取得します。

org.apache.qpid.client.AMQSession_0_10@420e44
org.apache.qpid.client.AMQSession_0_10@d76237
org.apache.qpid.client.AMQSession_0_10@d76237
org.apache.qpid.client.AMQSession_0_10@7148e9

一意であることが保証されていないことを理解しましたが、2つの別々のスレッドで同じセッションオブジェクトhashcode()を返すことをどのように証明または反証できますか?createSession()

4

1 に答える 1

0

Turned out to be more of a Java object equivalency question rather than anything to do with qpid or messaging.

Instead of printing hashcodes, I inserted the Session objects themselves into a Vector<Session> and compared them (==). Turns out they were all unique across all threads.

于 2012-08-23T14:51:58.780 に答える