Example #1
0
 def direct_message_publish_outbound_with_all_props_on_backpressure_wait(
         messaging_service: MessagingService, destination, message,
         buffer_capacity, message_count):
     """ to publish outbound message using back pressure"""
     try:
         direct_publish_service = messaging_service.create_direct_message_publisher_builder() \
             .on_back_pressure_wait(buffer_capacity=buffer_capacity) \
             .build()
         direct_publish_service.start()
         outbound_msg = messaging_service.message_builder() \
             .with_property("custom_key", "custom_value") \
             .with_expiration(SolaceConstants.MESSAGE_EXPIRATION) \
             .with_priority(SolaceConstants.MESSAGE_PRIORITY) \
             .with_sequence_number(SolaceConstants.MESSAGE_SEQUENCE_NUMBER) \
             .with_application_message_id(constants.APPLICATION_MESSAGE_ID) \
             .with_application_message_type("app_msg_type") \
             .with_http_content_header("text/html", "utf-8") \
             .build(message)
         for e in range(message_count):
             direct_publish_service.publish(destination=destination,
                                            message=outbound_msg)
     except PublisherOverflowError:
         PublisherOverflowError("Queue maximum limit is reached")
     finally:
         util.publisher_terminate(direct_publish_service)
Example #2
0
 def direct_message_publish_on_backpressure_reject(
         messaging_service: MessagingService, destination, message,
         buffer_capacity, message_count):
     """ to publish str or byte array type message using back pressure"""
     try:
         direct_publish_service = messaging_service.create_direct_message_publisher_builder() \
             .on_back_pressure_reject(buffer_capacity=buffer_capacity) \
             .build()
         direct_publish_service.start()
         for e in range(message_count):
             direct_publish_service.publish(destination=destination,
                                            message=message)
     except PublisherOverflowError:
         PublisherOverflowError("Queue maximum limit is reached")
     finally:
         util.publisher_terminate(direct_publish_service)
    def direct_message_publish_without_backpressure(
            messaging_service: MessagingService, destination, message,
            message_count):
        """ to publish str or byte array type message using back pressure"""
        try:
            direct_publish_service = messaging_service.create_direct_message_publisher_builder() \
                .build()
            direct_publish_service.start_async()

            HowToDirectMessagingHealthCheckSampler.PUBLISHER_READINESS_SET_COUNTER += 1
            direct_publish_service.set_publisher_readiness_listener(
                listener=PublisherReadinessListenerImpl())

            for e in range(message_count):
                direct_publish_service.publish(destination=destination,
                                               message=message)
                print(f"{e} message(s) sent")
        except PublisherOverflowError:
            PublisherOverflowError("Queue maximum limit is reached")
        finally:
            direct_publish_service.terminate()