11"""AMQP wire factory implementation"""
22
33import secrets
4- from typing import Optional , Callable , Any , cast
4+ from typing import Any , Callable , Optional , cast
5+
56from typing_extensions import Unpack
67
78try :
1314 ) from e
1415
1516from asyncapi_python .kernel .wire import AbstractWireFactory , EndpointParams
16- from asyncapi_python .kernel .wire .typing import Producer , Consumer
17+ from asyncapi_python .kernel .wire .typing import Consumer , Producer
1718
18- from .message import AmqpWireMessage , AmqpIncomingMessage
19- from .producer import AmqpProducer
2019from .consumer import AmqpConsumer
20+ from .message import AmqpIncomingMessage , AmqpWireMessage
21+ from .producer import AmqpProducer
2122from .resolver import resolve_amqp_config
2223
2324
@@ -31,7 +32,6 @@ class AmqpWire(AbstractWireFactory[AmqpWireMessage, AmqpIncomingMessage]):
3132 def __init__ (
3233 self ,
3334 connection_url : str ,
34- service_name : str = "app" ,
3535 robust : bool = False ,
3636 reconnect_interval : float = 1.0 ,
3737 max_reconnect_interval : float = 60.0 ,
@@ -45,7 +45,6 @@ def __init__(
4545
4646 Args:
4747 connection_url: AMQP connection URL
48- service_name: Service name prefix for app_id
4948 robust: Enable robust connection with auto-reconnect (default: False)
5049 reconnect_interval: Initial reconnect interval in seconds (for robust mode)
5150 max_reconnect_interval: Maximum reconnect interval in seconds (for robust mode)
@@ -55,9 +54,10 @@ def __init__(
5554 on_connection_lost: Callback when connection is lost (for non-robust mode)
5655 """
5756 self ._connection_url = connection_url
58- # Generate app_id with service name plus 8 random hex characters
57+ # Generate fallback app_id with random hex characters
58+ # Note: For RPC, app_id should be provided via EndpointParams from application level
5959 random_hex = secrets .token_hex (4 ) # 4 bytes = 8 hex chars
60- self ._app_id = f"{ service_name } -{ random_hex } "
60+ self ._app_id = f"wire -{ random_hex } "
6161 self ._connection : AbstractConnection | None = None
6262 self ._robust = robust
6363 self ._reconnect_interval = reconnect_interval
@@ -135,8 +135,12 @@ async def create_consumer(
135135 # Generate operation name from available information
136136 operation_name = self ._generate_operation_name (kwargs )
137137
138+ # Use provided app_id if available, otherwise use instance app_id
139+ # This allows application-level control over queue naming
140+ app_id = kwargs .get ("app_id" , self ._app_id )
141+
138142 # Resolve AMQP configuration using pattern matching
139- config = resolve_amqp_config (kwargs , operation_name , self . _app_id )
143+ config = resolve_amqp_config (kwargs , operation_name , app_id )
140144
141145 connection = await self ._get_connection ()
142146
@@ -154,8 +158,12 @@ async def create_producer(
154158 # Generate operation name from available information
155159 operation_name = self ._generate_operation_name (kwargs )
156160
161+ # Use provided app_id if available, otherwise use instance app_id
162+ # This allows application-level control over queue naming
163+ app_id = kwargs .get ("app_id" , self ._app_id )
164+
157165 # Resolve AMQP configuration using pattern matching
158- config = resolve_amqp_config (kwargs , operation_name , self . _app_id )
166+ config = resolve_amqp_config (kwargs , operation_name , app_id )
159167
160168 connection = await self ._get_connection ()
161169
0 commit comments