//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements.  See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License.  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package org.apache.activemq.store.kahadb.data;

option java_multiple_files = true;
option java_outer_classname = "JournalData";

enum KahaEntryType {
  //| option java_create_message="true";
  KAHA_TRACE_COMMAND = 0;
  KAHA_ADD_MESSAGE_COMMAND = 1;
  KAHA_REMOVE_MESSAGE_COMMAND = 2;
  KAHA_PREPARE_COMMAND = 3;
  KAHA_COMMIT_COMMAND = 4;
  KAHA_ROLLBACK_COMMAND = 5;
  KAHA_REMOVE_DESTINATION_COMMAND = 6;
  KAHA_SUBSCRIPTION_COMMAND = 7;
  KAHA_PRODUCER_AUDIT_COMMAND = 8;
  KAHA_ACK_MESSAGE_FILE_MAP_COMMAND = 9;
  KAHA_UPDATE_MESSAGE_COMMAND = 10;
  KAHA_ADD_SCHEDULED_JOB_COMMAND = 11;
  KAHA_RESCHEDULE_JOB_COMMAND = 12;
  KAHA_REMOVE_SCHEDULED_JOB_COMMAND = 13;
  KAHA_REMOVE_SCHEDULED_JOBS_COMMAND = 14;
  KAHA_DESTROY_SCHEDULER_COMMAND = 15;
  KAHA_REWRITTEN_DATA_FILE_COMMAND = 16;
}

message KahaTraceCommand {
  // We make use of the wonky comment style bellow because the following options
  // are not valid for protoc, but they are valid for the ActiveMQ proto compiler.
  // In the ActiveMQ proto compiler, comments terminate with the pipe character: |

  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaTraceCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required string message = 1;
}

message KahaAddMessageCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaAddMessageCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  optional KahaTransactionInfo transaction_info=1;
  required KahaDestination destination = 2;
  required string messageId = 3;
  required bytes message = 4;
  optional int32 priority =5 [default = 4];
  optional bool prioritySupported = 6;
}

message KahaUpdateMessageCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaUpdateMessageCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";
  required KahaAddMessageCommand message = 1;
}

message KahaRemoveMessageCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaRemoveMessageCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  optional KahaTransactionInfo transaction_info=1;
  required KahaDestination destination = 2;
  required string messageId = 3;
  optional bytes ack = 4;
  optional string subscriptionKey = 5;  // Set if it is a topic ack.
}

message KahaPrepareCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaPrepareCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required KahaTransactionInfo transaction_info=1;
}

message KahaCommitCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaCommitCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required KahaTransactionInfo transaction_info=1;
}

message KahaRollbackCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaRollbackCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required KahaTransactionInfo transaction_info=1;
}

message KahaRemoveDestinationCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaRemoveDestinationCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required KahaDestination destination = 1;
}

message KahaSubscriptionCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaSubscriptionCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required KahaDestination destination = 1;
  required string subscriptionKey = 2;
  optional bool retroactive = 3;
  optional bytes subscriptionInfo = 4;
}

message KahaProducerAuditCommand {
  // We make use of the wonky comment style bellow because the following options
  // are not valid for protoc, but they are valid for the ActiveMQ proto compiler.
  // In the ActiveMQ proto compiler, comments terminate with the pipe character: |

  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaProducerAuditCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required bytes audit = 1;
}

message KahaAckMessageFileMapCommand {
  // We make use of the wonky comment style bellow because the following options
  // are not valid for protoc, but they are valid for the ActiveMQ proto compiler.
  // In the ActiveMQ proto compiler, comments terminate with the pipe character: |

  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaAckMessageFileMapCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required bytes ackMessageFileMap = 1;
}

message KahaDestination {
  enum DestinationType {
    QUEUE = 0;
    TOPIC = 1;
    TEMP_QUEUE = 2;
    TEMP_TOPIC = 3;
  }

  required DestinationType type = 1 [default = QUEUE];
  required string name = 2;
}

message KahaTransactionInfo {
  optional KahaLocalTransactionId local_transaction_id=1;
  optional KahaXATransactionId xa_transaction_id=2;
  optional KahaLocation previous_entry=3;
}

message KahaLocalTransactionId {
  required string connection_id=1;
  required int64 transaction_id=1;
}

message KahaXATransactionId {
  required int32 format_id = 1;
  required bytes branch_qualifier = 2;
  required bytes global_transaction_id = 3;
}

message KahaLocation {
  required int32 log_id = 1;
  required int32 offset = 2;
}

message KahaAddScheduledJobCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaAddScheduledJobCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required string scheduler=1;
  required string job_id=2;
  required int64 start_time=3;
  required string cron_entry=4;
  required int64 delay=5;
  required int64 period=6;
  required int32 repeat=7;
  required bytes payload=8;
  required int64 next_execution_time=9;
}

message KahaRescheduleJobCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaRescheduleJobCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required string scheduler=1;
  required string job_id=2;
  required int64 execution_time=3;
  required int64 next_execution_time=4;
  required int32 rescheduled_count=5;
}

message KahaRemoveScheduledJobCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaRemoveScheduledJobCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required string scheduler=1;
  required string job_id=2;
  required int64 next_execution_time=3;
}

message KahaRemoveScheduledJobsCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaRemoveScheduledJobsCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required string scheduler=1;
  required int64 start_time=2;
  required int64 end_time=3;
}

message KahaDestroySchedulerCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaDestroySchedulerCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required string scheduler=1;
}

message KahaRewrittenDataFileCommand {
  //| option java_implments = "org.apache.activemq.store.kahadb.JournalCommand<KahaRewrittenDataFileCommand>";
  //| option java_visitor = "org.apache.activemq.store.kahadb.Visitor:void:java.io.IOException";
  //| option java_type_method = "KahaEntryType";

  required int32 sourceDataFileId = 1;
  optional int32 rewriteType = 2;
  optional bool skipIfSourceExists = 3 [default = true];

}

// TODO things to ponder
// should we move more message fields
// that are set by the sender (and rarely required by the broker
// into the Properties object?
