This commit is contained in:
2026-02-10 08:19:10 +07:00
parent eb99df02c9
commit 4019b35574
3 changed files with 29 additions and 15 deletions

View File

@@ -104,7 +104,7 @@ function log_trace(correlation_id::String, message::String)
timestamp = Dates.now() # Get current timestamp
@info "[$timestamp] [Correlation: $correlation_id] $message" # Log formatted message
end
2112
""" smartsend - Send data either directly via NATS or via a fileserver URL, depending on payload size
@@ -346,8 +346,7 @@ function smartreceive(
max_delay::Int = 5000
)
# Parse the envelope
env = MessageEnvelope(String(msg.data)) # Parse NATS message data as JSON envelope
env = MessageEnvelope(String(msg.payload)) # Parse NATS message data as JSON envelope
log_trace(env.correlation_id, "Processing received message") # Log message processing start
# Check transport type

View File

@@ -66,17 +66,16 @@ function test_large_binary_receive()
conn = NATS.connect(NATS_URL)
NATS.subscribe(conn, SUBJECT) do msg
log_trace("Received message on $(msg.subject)")
log_trace("Received message:\n$msg")
# Use SmartReceive to handle the data
result = SmartReceive(msg)
# Use NATSBridge.smartreceive to handle the data
result = NATSBridge.smartreceive(msg)
println("envelope----- ", result.envelope)
# Check transport type
if result.envelope.transport == "direct"
log_trace("Received direct transport with $(length(result.data)) bytes")
log_trace("Received direct transport with ---- bytes")
else
# For link transport, result.data is the URL
log_trace("Received link transport at $(result.data)")
log_trace("Received link transport at ---")
end
# Verify the received data matches the original
@@ -102,7 +101,7 @@ function test_large_binary_receive()
end
# Keep listening for 10 seconds
sleep(10)
sleep(60)
NATS.drain(conn)
end
@@ -111,12 +110,28 @@ println("Starting large binary payload test...")
println("Correlation ID: $correlation_id")
println("Large file: $LARGE_FILE_PATH")
# Run sender first
println("start smartsend")
test_large_binary_send()
# # Run sender first
# println("start smartsend")
# test_large_binary_send()
# Run receiver
println("testing smartreceive")
test_large_binary_receive()
println("Test completed.")

BIN
test_output.bin Normal file

Binary file not shown.