update
This commit is contained in:
@@ -431,7 +431,8 @@ function smartsend(
|
||||
receiver_id::String = "",
|
||||
reply_to::String = "",
|
||||
reply_to_msg_id::String = "",
|
||||
is_publish::Bool = true # some time the user want to get env and env_json_str from this function without publishing the msg
|
||||
is_publish::Bool = true, # some time the user want to get env and env_json_str from this function without publishing the msg
|
||||
NATS_connection::Union{NATS.Connection, Nothing} = nothing # a provided connection saves establishing connection overhead.
|
||||
) where {T1<:Any}
|
||||
|
||||
# Generate correlation ID if not provided
|
||||
@@ -515,8 +516,12 @@ function smartsend(
|
||||
)
|
||||
|
||||
env_json_str = envelope_to_json(env) # Convert envelope to JSON
|
||||
if is_publish
|
||||
if is_publish == false
|
||||
# skip publish a message
|
||||
elseif is_publish == true && NATS_connection === nothing
|
||||
publish_message(broker_url, subject, env_json_str, cid) # Publish message to NATS
|
||||
elseif is_publish == true && NATS_connection !== nothing
|
||||
publish_message(NATS_connection, subject, env_json_str, cid) # Publish message to NATS
|
||||
end
|
||||
|
||||
return (env, env_json_str)
|
||||
@@ -673,6 +678,10 @@ connection management and logging.
|
||||
"""
|
||||
function publish_message(broker_url::String, subject::String, message::String, correlation_id::String)
|
||||
conn = NATS.connect(broker_url) # Create NATS connection
|
||||
publish_message(conn, subject, message, correlation_id)
|
||||
end
|
||||
|
||||
function publish_message(conn::NATS.Connection, subject::String, message::String, correlation_id::String)
|
||||
try
|
||||
NATS.publish(conn, subject, message) # Publish message to NATS
|
||||
log_trace(correlation_id, "Message published to $subject") # Log successful publish
|
||||
@@ -1055,7 +1064,7 @@ function plik_oneshot_upload(file_server_url::String, filepath::String)
|
||||
end
|
||||
|
||||
function _get_payload_bytes(data)
|
||||
@error "didn't implement yet"
|
||||
@error "Didn't implement yet. The developer will implement this function later."
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user