~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/rabbitmq/rabbitmq_handler.cc

  • Committer: Marcus Eriksson
  • Date: 2011-03-31 13:02:08 UTC
  • mto: This revision was merged to the branch mainline in revision 2263.
  • Revision ID: krummas@gmail.com-20110331130208-owwps8woa5qx31d1
add mutex - TransactionAppliers are not single threaded

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
    exchange(rabbitMQExchange), 
51
51
    routingKey(rabbitMQRoutingKey)
52
52
{
 
53
  pthread_mutex_init(&publishLock, NULL);
53
54
  connect();
54
55
}
55
56
 
56
57
RabbitMQHandler::~RabbitMQHandler()
57
58
{
 
59
  pthread_mutex_destroy(&publishLock);
58
60
  disconnect();
59
61
}
60
62
 
62
64
                              const int length)
63
65
throw(rabbitmq_handler_exception)
64
66
{
 
67
  pthread_mutex_lock(&publishLock);
65
68
  amqp_bytes_t b;
66
69
  b.bytes= message;
67
70
  b.len= length;
75
78
                         NULL,
76
79
                         b) < 0)
77
80
  {
 
81
    pthread_mutex_unlock(&publishLock);
78
82
    throw rabbitmq_handler_exception("Could not publish message");
79
83
  }
 
84
  pthread_mutex_unlock(&publishLock);
80
85
 
81
86
}
82
87