Exemplo n.º 1
0
 def test_failure( self ):
   consumer = MQConsumer(mqManager = self.myManager, mqURI  = "fake.cern.ch::Queue::FakeQueue", consumerId ='consumer4')
   result = consumer.close()
   self.assertTrue(result['OK'])
   result = consumer.close()
   self.assertFalse(result['OK'])
   self.assertEqual(result['Message'], 'MQ connection failure ( 1142 : Failed to stop the connection!The messenger consumer4 does not exist!)')
Exemplo n.º 2
0
 def test_failure(self):
     consumer = MQConsumer(mqManager=self.myManager,
                           mqURI="fake.cern.ch::Queue::FakeQueue",
                           consumerId='consumer1')
     result = consumer.get()
     self.assertFalse(result['OK'])
     self.assertEqual(result['Message'],
                      'No messages ( 1141 : No messages in queue)')
Exemplo n.º 3
0
 def test_failure(self):
     consumer = MQConsumer(mqManager=self.myManager,
                           mqURI="fake.cern.ch::Queues::FakeQueue",
                           consumerId="consumer1")
     result = consumer.get()
     self.assertFalse(result["OK"])
     self.assertEqual(result["Message"],
                      "No messages ( 1141 : No messages in queue)")
Exemplo n.º 4
0
 def test_failure(self):
   consumer = MQConsumer(mqManager=self.myManager, mqURI="fake.cern.ch::Queues::FakeQueue", consumerId='consumer4')
   result = consumer.close()
   self.assertTrue(result['OK'])
   result = consumer.close()
   self.assertFalse(result['OK'])
   self.assertEqual(
       result['Message'],
       'MQ connection failure ( 1142 : Failed to stop the connection!The messenger consumer4 does not exist!)')
Exemplo n.º 5
0
def createConsumer(mqURI, callback=generateDefaultCallback()):
    """ Function creates MQConsumer. All parameters are taken
      from the Configuration Service based on the mqURI
      value.
  Args:
    mqURI(str):Pseudo URI identifing MQ service. It has the following format
              mqConnection::DestinationType::DestinationName
              e.g. blabla.cern.ch::Queue::MyQueue1
    callback: callback function that can be used to process the incoming messages
  Returns:
    S_OK/S_ERROR: with the consumer object in S_OK.
  """
    result = _setupConnection(mqURI=mqURI, mType="consumer")
    if not result['OK']:
        gLogger.error('Failed to createConsumer:', result['Message'])
        return result
    return S_OK(
        MQConsumer(mqManager=connectionManager,
                   mqURI=mqURI,
                   consumerId=result['Value'],
                   callback=callback))
Exemplo n.º 6
0
 def test_failure2(self):
     consumer = MQConsumer(mqManager=self.myManager,
                           mqURI="fake.cern.ch::Queues::FakeQueue",
                           consumerId="consumer4")
     consumer2 = MQConsumer(mqManager=self.myManager,
                            mqURI="fake.cern.ch::Queues::FakeQueue",
                            consumerId="consumer2")
     result = consumer.close()
     self.assertTrue(result["OK"])
     result = consumer.close()
     self.assertFalse(result["OK"])
     self.assertEqual(
         result["Message"],
         "MQ connection failure ( 1142 : Failed to stop the connection!The messenger consumer4 does not exist!)",
     )
     result = consumer2.close()
     self.assertTrue(result["OK"])
     result = consumer2.close()
     self.assertFalse(result["OK"])
     self.assertEqual(
         result["Message"],
         "MQ connection failure ( 1142 : Failed to stop the connection!The messenger consumer2 does not exist!)",
     )
Exemplo n.º 7
0
 def test_success(self):
     consumer = MQConsumer(mqManager=self.myManager,
                           mqURI="fake.cern.ch::Queue::FakeQueue",
                           consumerId='consumer4')
     result = consumer.close()
     self.assertTrue(result['OK'])
Exemplo n.º 8
0
 def test_sucess(self):
     consumer = MQConsumer(mqManager=self.myManager,
                           mqURI="bad.cern.ch::Queue::FakeQueue",
                           consumerId='consumer1')
     result = consumer.get()
     self.assertFalse(result['OK'])
Exemplo n.º 9
0
 def test_success( self ):
   consumer = MQConsumer(mqManager = self.myManager, mqURI  = "fake.cern.ch::Queue::FakeQueue", consumerId ='consumer4')
   result = consumer.close()
   self.assertTrue(result['OK'])
Exemplo n.º 10
0
 def test_sucess( self ):
   consumer = MQConsumer(mqManager = self.myManager, mqURI  = "bad.cern.ch::Queue::FakeQueue", consumerId = 'consumer1')
   result = consumer.get()
   self.assertFalse(result['OK'])
Exemplo n.º 11
0
 def test_failure( self ):
   consumer = MQConsumer(mqManager = self.myManager, mqURI  = "fake.cern.ch::Queue::FakeQueue", consumerId = 'consumer1')
   result = consumer.get()
   self.assertFalse(result['OK'])
   self.assertEqual(result['Message'], 'No messages ( 1141 : No messages in queue)')