Exemple #1
0
static void
afstomp_create_connect_frame(STOMPDestDriver *self, stomp_frame* frame)
{
  stomp_frame_init(frame, "CONNECT", sizeof("CONNECT"));
  stomp_frame_add_header(frame, "login", self->user);
  stomp_frame_add_header(frame, "passcode", self->password);
};
Exemple #2
0
static gboolean
afstomp_worker_publish(STOMPDestDriver *self, LogMessage *msg)
{
  gboolean success = TRUE;
  SBGString *body = NULL;
  stomp_frame frame;
  stomp_frame recv_frame;
  gchar seq_num[16];

  if (!self->conn)
    {
      msg_error("STOMP server is not connected, not sending message!", NULL);
      return FALSE;
    }

  body = sb_gstring_acquire();
  stomp_frame_init(&frame, "SEND", sizeof("SEND"));

  if (self->persistent)
    stomp_frame_add_header(&frame, "persistent", "true");

  stomp_frame_add_header(&frame, "destination", self->destination);
  if (self->ack_needed)
    {
      g_snprintf(seq_num, sizeof(seq_num), "%i", self->super.seq_num);
      stomp_frame_add_header(&frame, "receipt", seq_num);
    };

  value_pairs_foreach(self->vp, afstomp_vp_foreach, msg,
                      self->super.seq_num, LTZ_SEND,
                      &self->template_options, &frame);

  afstomp_set_frame_body(self, body, &frame, msg);

  if (!afstomp_send_frame(self, &frame))
    {
      msg_error("Error while inserting into STOMP server", NULL);
      success = FALSE;
    }

  if (success && self->ack_needed)
    success = stomp_receive_frame(self->conn, &recv_frame);

  sb_gstring_release(body);

  return success;
}
Exemple #3
0
static gboolean
afstomp_vp_foreach(const gchar *name, TypeHint type, const gchar *value,
                   gpointer user_data)
{
  stomp_frame *frame = (stomp_frame *) (user_data);

  stomp_frame_add_header(frame, name, value);

  return FALSE;
}
Exemple #4
0
Test(stomp_proto, test_generate_gstring_from_frame)
{
  stomp_frame frame;
  GString *actual;

  stomp_frame_init(&frame, "SEND", sizeof("SEND"));
  stomp_frame_add_header(&frame, "header_name", "header_value");
  stomp_frame_set_body(&frame, "body", sizeof("body"));
  actual = create_gstring_from_frame(&frame);
  cr_assert_str_eq(actual->str, "SEND\nheader_name:header_value\n\nbody", "Generated stomp frame does not match");
  stomp_frame_deinit(&frame);
};