Skip to content

BOOST.ThumbnailGenerator

A Java microservice that generates thumbnail images from various file formats (images, PDFs, etc.). It operates as a message queue consumer, receiving requests via AMQP/JMS, generating 200px PNG thumbnails, and responding with the result and image metadata.

Architecture

BOOST.ThumbnailGenerator runs as a standalone service that:

  1. Connects to an AMQP message broker
  2. Listens on the queue boostv3.thumbnailgenerator
  3. Receives file generation requests containing a pre-signed URL
  4. Downloads and processes the file using ImageMagick
  5. Responds via JMS with the thumbnail path and metadata

Prerequisites

  • Java 21
  • ImageMagick (must be installed and accessible on the system PATH)
  • AMQP Message Broker (e.g., RabbitMQ)

Configuration

Configuration is defined in config.properties:

properties
broker_url=amqp://172.16.200.32:5672
message_queue_name=boostv3.thumbnailgenerator
source_path=c:/x
output_path=c:/x
log_file=
PropertyDescription
broker_urlAMQP broker connection URL
message_queue_nameQueue name to consume from
source_pathTemporary directory for downloaded source files
output_pathRoot directory for generated thumbnails
log_fileOptional log file path

Message Format

Request (Incoming JMS Message)

json
{
  "tenantUUID": "string",
  "preSignedUrl": "string"
}
FieldDescription
tenantUUIDTenant identifier for multi-tenant file organization
preSignedUrlPre-signed URL to download the source file

Response (JMS Reply)

json
{
  "success": true,
  "thumbnailFileName": "uuid.png",
  "pathPrefix": "tenantUUID/2025-01",
  "mimeType": "image/png",
  "metaData": {
    "width": 800,
    "height": 600,
    "format": "PNG",
    "colorSpace": "sRGB",
    "depth": 8
  }
}
FieldDescription
successWhether thumbnail generation succeeded
thumbnailFileNameGenerated thumbnail filename (UUID-based)
pathPrefixStorage path prefix: {tenantUUID}/{YYYY-MM}
mimeTypeDetected MIME type of the source file
metaDataExtracted image properties

Thumbnail Generation Process

  1. The source file is downloaded from the pre-signed URL via HTTP
  2. MIME type is detected using Apache Tika
  3. Image orientation (landscape/portrait) is determined via ImageMagick's identify command
  4. The image is resized to 200px (width for portrait, height for landscape) with a white background
  5. Output is saved as PNG in the path {output_path}/{tenantUUID}/{YYYY-MM}/{uuid}.png
  6. Source file is deleted after processing

File Organization

Generated thumbnails are organized by tenant and date:

{output_path}/
  {tenantUUID}/
    {YYYY-MM}/
      {uuid}.png

Dependencies

DependencyVersionPurpose
qpid-jms-client2.5.0AMQP messaging client
jakarta.jms-api3.1.0JMS API
im4java1.4.0ImageMagick Java wrapper
tika-core3.0.0MIME type detection
okhttp4.12.0HTTP file downloads
BoostMiddlewareinternalShared BOOST utilities
JsoninternalJSON handling

Running the Service

bash
java -cp target/classes com.luqon.boost.thumbnailgenerator.ThumbnailServer

The service connects to the configured broker and blocks until stdin is closed.