Skip to content

Commit

Permalink
Test with ibm mq
Browse files Browse the repository at this point in the history
There is still an issue with
read messsage annotations
  • Loading branch information
MarcialRosales committed Jun 5, 2024
1 parent 85f300c commit d8f7a42
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
3 changes: 2 additions & 1 deletion deps/amqp10_client/src/amqp10_client_session.erl
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ filter_capability(V) when is_binary(V) ->
filter_capability({T, _} = V) when is_atom(T) ->
%% looks like an already tagged type, just pass it through
V.

% https://people.apache.org/~rgodfrey/amqp-1.0/apache-filters.html
translate_legacy_amqp_headers_binding(LegacyHeaders) ->
{map,
Expand Down Expand Up @@ -867,6 +867,7 @@ send_attach(Send, #{name := Name, role := RoleTuple} = Args, {FromPid, _},
rcv_settle_mode = rcv_settle_mode(Args),
target = Target,
max_message_size = MaxMessageSize},
ct:log("Attach frame ~p", [Attach]),
ok = Send(Attach, State),

Ref = make_link_ref(Role, self(), OutHandle),
Expand Down
35 changes: 18 additions & 17 deletions deps/amqp10_client/test/system_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ all() ->
{group, rabbitmq},
{group, rabbitmq_strict},
{group, activemq},
% {group, ibmmq}
{group, ibmmq},
{group, activemq_no_anon},
{group, mock}
].
Expand All @@ -33,7 +33,10 @@ groups() ->
[
{rabbitmq, [], shared()},
{activemq, [], shared()},
{ibmmq, [], test()},
{ibmmq, [], [
open_close_connection,
basic_roundtrip_ibmmq
]},
{rabbitmq_strict, [], [
basic_roundtrip_tls,
roundtrip_tls_global_config,
Expand Down Expand Up @@ -62,12 +65,6 @@ groups() ->
]}
].

test() ->
[
open_close_connection,
basic_roundtrip
].

shared() ->
[
open_close_connection,
Expand Down Expand Up @@ -350,7 +347,7 @@ basic_roundtrip_ibmmq(Config) ->
Hostname = ?config(rmq_hostname, Config),
Port = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_amqp),
OpenConf = #{address => Hostname, port => Port, sasl => ?config(sasl, Config)},
roundtrip(OpenConf, [{body, <<"banana">>}, {destination, <<"DEV.QUEUE.1">>}]).
roundtrip(OpenConf, [{body, <<"banana">>}, {destination, <<"DEV.QUEUE.3">>}]).

roundtrip(OpenConf) ->
roundtrip(OpenConf, []).
Expand All @@ -361,7 +358,7 @@ roundtrip(OpenConf, Args) ->
{ok, Connection} = amqp10_client:open_connection(OpenConf),
{ok, Session} = amqp10_client:begin_session(Connection),
ct:log("Session attached "),
SenderAttachArgs = #{name => <<"banana-sender">>,
SenderAttachArgs = #{name => <<"banana-sender:DEV.QUEUE.3">>,
role => {sender, #{address => Destination,
durable => unsettled_state,
capabilities => <<"queue">>}},
Expand All @@ -376,12 +373,14 @@ roundtrip(OpenConf, Args) ->
ct:log("Sender attached "),

Now = os:system_time(millisecond),
Props = #{creation_time => Now,
message_id => <<"my message ID">>,
correlation_id => <<"my correlation ID">>,
Props = #{content_encoding => <<"my content encoding">>,
content_type => <<"my content type">>,
content_encoding => <<"my content encoding">>,
group_id => <<"my group ID">>},
correlation_id => <<"my correlation ID">>,
creation_time => Now,
group_id => <<"my group ID">>,
message_id => <<"my message ID">>,
to => Destination
},
Msg0 = amqp10_msg:new(<<"my-tag">>, Body, true),
Msg1 = amqp10_msg:set_application_properties(#{"a_key" => "a_value"}, Msg0),
Msg2 = amqp10_msg:set_properties(Props, Msg1),
Expand All @@ -403,12 +402,14 @@ roundtrip(OpenConf, Args) ->
properties => #{}
},
{ok, Receiver} = amqp10_client:attach_link(Session, ReceiverAttachArgs),
{ok, OutMsg} = amqp10_client:get_msg(Receiver, 4 * 60_000),
{ok, OutMsg} = amqp10_client:get_msg(Receiver, 4_000),
ok = amqp10_client:end_session(Session),
ok = amqp10_client:close_connection(Connection),

% ct:pal(?LOW_IMPORTANCE, "roundtrip message Out: ~tp~nIn: ~tp~n", [OutMsg, Msg]),
?assertMatch(Props, amqp10_msg:properties(OutMsg)),
ActualProps = amqp10_msg:properties(OutMsg),
[ ?assertMatch(V, maps:get(K, ActualProps)) || K := V <- Props, K =/= creation_time],

?assertEqual(#{<<"a_key">> => <<"a_value">>}, amqp10_msg:application_properties(OutMsg)),
?assertMatch(#{<<"x-key">> := <<"x-value">>,
<<"x_key">> := <<"x_value">>}, amqp10_msg:message_annotations(OutMsg)),
Expand Down

0 comments on commit d8f7a42

Please sign in to comment.