summaryrefslogtreecommitdiff
path: root/java/newclient/src/main/java/org/apache/qpid/nclient/amqp/event/AMQPMethodEvent.java
blob: c6641890e06c80847adfedaa490318074da89c63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package org.apache.qpid.nclient.amqp.event;

import org.apache.qpid.framing.AMQMethodBody;

/**
 * This class is exactly the same as the AMQMethod event.
 * Except I renamed requestId to corelationId, so I could use it both ways.
 * 
 * I didn't want to modify anything in common so that there is no
 * impact on the existing code.
 *
 */
public class AMQPMethodEvent<M extends AMQMethodBody>
{

    private final M _method;

    private final int _channelId;

    /**
     * This is the rquest id from the broker when it sent me a request
     * when I respond I remember this id and copy this to the outgoing
     * response. 
     */
    private final long _correlationId;

    /**
     * I could use _correlationId, bcos when I send a request
     * this field is blank and is only used internally. But I 
     * used a seperate field to make it more clear.
     */
    private long _localCorrletionId = 0;

    public AMQPMethodEvent(int channelId, M method, long correlationId, long localCorrletionId)
    {
	_channelId = channelId;
	_method = method;
	_correlationId = correlationId;
	_localCorrletionId = localCorrletionId;
    }

    public AMQPMethodEvent(int channelId, M method, long correlationId)
    {
	_channelId = channelId;
	_method = method;
	_correlationId = correlationId;
    }

    public M getMethod()
    {
	return _method;
    }

    public int getChannelId()
    {
	return _channelId;
    }

    public long getCorrelationId()
    {
	return _correlationId;
    }

    public long getLocalCorrelationId()
    {
	return _localCorrletionId;
    }

    public String toString()
    {
	StringBuilder buf = new StringBuilder("Method event: \n");
	buf.append("Channel id: \n").append(_channelId);
	buf.append("Method: \n").append(_method);
	buf.append("Request Id: ").append(_correlationId);
	buf.append("Local Correlation Id: ").append(_localCorrletionId);
	return buf.toString();
    }
}