Skip to content

Commit 99f53c0

Browse files
committed
QPID-4967 - Added the message transmit linkage from python.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1501046 13f79535-47bb-0310-9956-ffa450edef68
1 parent 344fd5a commit 99f53c0

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

qpid/extras/dispatch/include/qpid/dispatch/router.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,9 @@ void dx_router_send(dx_dispatch_t *dx,
4343
dx_field_iterator_t *address,
4444
dx_message_t *msg);
4545

46+
void dx_router_send2(dx_dispatch_t *dx,
47+
const char *address,
48+
dx_message_t *msg);
49+
4650

4751
#endif

qpid/extras/dispatch/src/python_embedded.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,36 @@ static void IoAdapter_dealloc(IoAdapter* self)
432432

433433
static PyObject* dx_python_send(PyObject *self, PyObject *args)
434434
{
435+
IoAdapter *ioa = (IoAdapter*) self;
435436
const char *address;
436437
PyObject *app_properties;
437438
PyObject *body;
438439
if (!PyArg_ParseTuple(args, "sOO", &address, &app_properties, &body))
439440
return 0;
440441

441-
// TODO - Compose and send a message
442-
442+
dx_composed_field_t *field = dx_compose(DX_PERFORMATIVE_HEADER, 0);
443+
dx_compose_start_list(field);
444+
dx_compose_insert_bool(field, 0); // durable
445+
dx_compose_end_list(field);
446+
447+
field = dx_compose(DX_PERFORMATIVE_PROPERTIES, field);
448+
dx_compose_start_list(field);
449+
dx_compose_insert_null(field); // message-id
450+
dx_compose_insert_null(field); // user-id
451+
dx_compose_insert_string(field, address); // to
452+
dx_compose_end_list(field);
453+
454+
field = dx_compose(DX_PERFORMATIVE_APPLICATION_PROPERTIES, field);
455+
dx_py_to_composed(app_properties, field);
456+
457+
field = dx_compose(DX_PERFORMATIVE_BODY_AMQP_VALUE, field);
458+
dx_py_to_composed(body, field);
459+
460+
dx_message_t *msg = dx_allocate_message();
461+
dx_message_compose_2(msg, field);
462+
dx_router_send2(ioa->dx, address, msg);
463+
dx_free_message(msg);
464+
dx_compose_free(field);
443465

444466
Py_INCREF(Py_None);
445467
return Py_None;

qpid/extras/dispatch/src/router_node.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,16 @@ void dx_router_send(dx_dispatch_t *dx,
613613
}
614614

615615

616+
void dx_router_send2(dx_dispatch_t *dx,
617+
const char *address,
618+
dx_message_t *msg)
619+
{
620+
dx_field_iterator_t *iter = dx_field_iterator_string(address, ITER_VIEW_ADDRESS_HASH);
621+
dx_router_send(dx, iter, msg);
622+
dx_field_iterator_free(iter);
623+
}
624+
625+
616626
//===============================================================================
617627
// Python Router Adapter
618628
//===============================================================================

0 commit comments

Comments
 (0)