Custom Actions

Create custom actions in qqq

Overview

Actions in qqq handle operations like queries, inserts, updates, and custom business logic. You can extend or replace built-in actions.

Action Types

  • Table Actions - CRUD operations on tables
  • Process Actions - Process execution
  • Custom Actions - Your own action types
  • Creating a Custom Action

    Extend the base action class:

    Java
    public class SendNotificationAction extends AbstractQActionFunction<SendNotificationInput, SendNotificationOutput> {
        @Override
        public SendNotificationOutput execute(SendNotificationInput input) throws QException {
            // Validate input
            if (input.getRecipient() == null) {
                throw new QException("Recipient is required");
            }
            
            // Execute action logic
            NotificationService.send(
                input.getRecipient(),
                input.getMessage()
            );
            
            return new SendNotificationOutput()
                .withSuccess(true)
                .withNotificationId(generateId());
        }
    }

    Input/Output Classes

    Define typed input and output:

    Java
    public class SendNotificationInput extends AbstractActionInput {
        private String recipient;
        private String message;
        private String channel; // email, sms, push
        // getters/setters
    }
    
    public class SendNotificationOutput extends AbstractActionOutput {
        private boolean success;
        private String notificationId;
        // getters/setters
    }

    Using Custom Actions

    Invoke from processes or other code:

    Java
    SendNotificationOutput output = new SendNotificationAction()
        .execute(new SendNotificationInput()
            .withRecipient("user@example.com")
            .withMessage("Your order shipped!")
            .withChannel("email"));

    Next Steps

  • Custom Widgets - UI extensions
  • Creating qBits - Package your extensions
  • Powered by qqq